Adding textbox in basic array

More
1 month 4 weeks ago #203209 by kratugoel
Also how would any code change if I have to change my question type from the default array to array (numbers)?

Please Log in to join the conversation.

More
1 month 4 weeks ago #203211 by tpartner

kratugoel wrote: Hi

I am trying to implement this solution but I am not able to. Would you happen to have a sample survey depicting this solution? Thank you for the assistance.

Joffm has already supplied a sample survey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
1 month 4 weeks ago #203213 by kratugoel
The sample survey provided is for the comment boxes. That works well for me so thank you for that. In that however, I was wondering how to implement the same comment box for array (numbers). Additionally, I was actually seeking a sample survey for the earlier solution provided by him where the large text box appears below the question(without the comment box).

Thank you

Please Log in to join the conversation.

More
1 month 4 weeks ago #203219 by tpartner

I was wondering how to implement the same comment box for array (numbers)

This will implement Joffm's last solution in an array-numbers question:

Q1<br />
<button class="btn btn-default btn-xs" data-backdrop="static" data-keyboard="false" data-target="#comments-{QID}" data-toggle="modal" type="button">Click to add a comment</button> 
<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		// Identify the questions
		var qArrayID = {QID};
		var qArray = $('#question'+qArrayID);
		var qComments = qArray.nextAll('.text-long:eq(0)');
 
		// Add some classes
		qArray.addClass('array-with-comments-question');
		$(qComments).each(function(i) {
			$(this).addClass('comments-question index-'+i).css({
				'position': 'absolute',
				'left': '-9999em'
			});
		});
 
		// Create the modal
		$('body').append('<div class="modal comments-modal" id="comments-'+qArrayID+'" tabindex="-1" role="dialog">\
							<div class="modal-dialog" role="document">\
								<div class="modal-content">\
									<div class="modal-header">\
										<h5 class="modal-title">'+$('.ls-label-question', qComments).html()+'</h5>\
									</div>\
									<div class="modal-body">\
									</div>\
									<div class="modal-footer">\
										<button type="button" class="btn btn-primary" data-dismiss="modal">Okay</button>\
										<button type="button" class="btn btn-secondary" data-dismiss="modal">Clear</button>\
									</div>\
								</div>\
							</div>\
						</div>');
 
		// Move textarea into modal
		$('#comments-'+qArrayID+' .modal-body').append($('textarea', qComments));
 
		// Modal button events
		$('#comments-'+qArrayID+' .modal-footer .btn-secondary').on('click', function(e) {
			$('#comments-'+qArrayID+' textarea').val('');
		});			
 
		// Interrupt the Next/Submit function (to put comments back in the form)
		$('#limesurvey').submit(function(e) {
			$('.answer-item:eq(0)', qComments).append($('#comments-'+qArrayID+' textarea:eq(0)'));
		});	
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...1(1).lss
File Size:22 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Attachments:
The following user(s) said Thank You: kratugoel

Please Log in to join the conversation.

More
1 month 4 weeks ago #203220 by tpartner

Additionally, I was actually seeking a sample survey for the earlier solution provided by him where the large text box appears below the question(without the comment box).

You will need to be more specific - there are over 75 posts in this thread.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in to join the conversation.

More
1 month 4 weeks ago - 1 month 4 weeks ago #203221 by Joffm
Replied by Joffm on topic Adding textbox in basic array

I was actually seeking a sample survey for the earlier solution provided by him where the large text box appears below the question(without the comment box).


Well, here is the explanation again.
Use two questions, a questiomn of type array and a question of type "long text".

Give the array question a css class "myarray" and the text question a css class "mytext"
Add this css snippet.
<style type="text/css">
.mytext .question-title-container, .mytext .question-valid-container {
  display:none;
}
.myarray .question-container {
    margin-bottom: 0em;
}
</style>

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 month 4 weeks ago by Joffm.
The following user(s) said Thank You: kratugoel

Please Log in to join the conversation.

More
1 month 4 weeks ago #203238 by kratugoel
Thank you Joffm for sending the solution again. I will try it again. Was making some error earlier. Would this solution work for Array (numbers) as well? Or is there some modifications?

Please Log in to join the conversation.

More
1 month 4 weeks ago #203239 by kratugoel
Thank you Tony Partner for sending the amended solution for array by numbers for the comment box.

Please Log in to join the conversation.

More
1 month 4 weeks ago #203242 by Joffm
Replied by Joffm on topic Adding textbox in basic array
Why should it not work?
You have two questions.
And you do nothing else than hide the question container of the second question and remove the space between them.

So it is absolutely independent of the type of question.

But instead of asking this and wait for an answer, just try.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: kratugoel

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now