Array with large text fields

More
1 week 3 days ago #169901 by nique
nique created the topic: Array with large text fields
I found this great thread with super helpful script by tpartner!



www.limesurvey.org/forum/can-i-do-this-w...-text-comment-fields

I am trying to edit the script slightly but am struggling.

On one page, I am presenting single arrays per question. This is just due to the nature of the question and how the researcher wants to present it.

I want to have each question/array have its own comment box - which includes some text specific to the question.

Unfortunately, this script picks up on all the comment boxes on the page and presents all 3, rather than just the one I want.

I am attaching my question group as an example of my survey -

File Attachment:

File Name: nique_mult...ents.lsg
File Size:19 KB


There will be more questions per page as well. Hope this makes sense and I can get some help.

Thanks in advance.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 week 3 days ago #169903 by holch
holch replied the topic: Array with large text fields
Ideally you always provide a .lss file that the forum helpers can just import and play with (of course stripped of everything unnecessary and focused on the problems in question). Otherwise the forum helpers have to create a survey and then import your question group, which also will only work, if the base language is right, etc.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
1 week 3 days ago #169904 by nique
nique replied the topic: Array with large text fields

File Attachment:

File Name: nique_mult...6-14.lss
File Size:30 KB



Apologies. LSS file attached with an example of one group of questions.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #169910 by tpartner
tpartner replied the topic: Array with large text fields
When providing examples, please give them in .lss (survey export) format so we don't have to spend time creating surveys.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #169911 by nique
nique replied the topic: Array with large text fields
Yep. Holch pointed this out and the reply there has the lss file.

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #169922 by tpartner
tpartner replied the topic: Array with large text fields
What is your LimeSurvey version?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #169930 by nique
nique replied the topic: Array with large text fields
2.59.

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #169932 by tpartner
tpartner replied the topic: Array with large text fields
In that case, this should work:

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify the questions
		var qArray = $('#question{QID}');
		var arrayLength = $('tr.answers-list', qArray).length;
		var qComments = qArray.nextAll('.text-long:lt('+arrayLength+')');
 
		// Add some classes
		qArray.addClass('array-with-comments-question');
		$(qComments).each(function(i) {
			$(this).addClass('comments-question index-{SGQ}-'+i);
		});
 
		// Insert the comments buttons
		$('table.questions-list col', qArray).removeAttr('width');
		$('table.questions-list thead tr', qArray).append('<td />');
		$('tr.answers-list', qArray).each(function(i) {
			$(this).append('<td><button class="comment-button" type="button" data-index="{SGQ}-'+i+'">Comments</button></td>');
		});
 
		// Put the comments questions into modal dialogs		
		$(qComments).dialog({
			autoOpen: false,
			width: 620,
			modal: true,
			resizable: false,
			draggable: false,
			closeOnEscape: true
		});
 
		// Click events for comments buttons
		$('.comment-button').click(function() {
			var thisIndex = $(this).attr('data-index');
			$('.comments-question.index-'+thisIndex).dialog('open');
		});	
 
		// Interrupt the Next/Submit function (to put comments back in the form)
		$('#movenextbtn, #movesubmitbtn').bind('click', function () {			
			qComments.hide();
			$('#limesurvey').append(qComments);
		});		
 
	});
</script>

Working survey attached:

File Attachment:

File Name: limesurvey...2497.lss
File Size:30 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!