Welcome, Guest
Username: Password: Remember me

TOPIC: Array Question with "Other" Answer

Array Question with "Other" Answer 1 month 3 weeks ago #121220

  • jelo
  • jelo's Avatar
  • Offline
  • Platinum Lime
  • Posts: 691
  • Thank you received: 79
  • Karma: 23
Is there an elegant way to keep the others fields at the bottom when applying the randomize option?
The administrator has disabled public write access.

Array Question with "Other" Answer 1 month 3 weeks ago #121265

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5017
  • Thank you received: 1035
  • Karma: 431
To do that, you would need to have the JS move the "Other" sub-question to the end of the array before inserting the text input.

So, for example, if your "Other" sub-question has a code of "99", something like this:

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify the questions
		var thisQuestion = $('#question'+{QID}+'');
		var nextQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');
 
		// Hide the short-text question
		$(nextQuestion).hide();
 
		// Move the "Other" row to the end (in case of randomization)
		$('table.subquestions-list', thisQuestion).append($('tr.answers-list[id$="X'+{QID}+'99"]'));
 
		// Add a class to the "N/A" column
		$('table.subquestions-list thead tr th:last', thisQuestion).addClass('na-column');
		$('table.subquestions-list tbody tr', thisQuestion).each(function(i) {
			$('td:last', this).addClass('na-column');
		});
 
		// Hide the "N/A" column
		$('.na-column', thisQuestion).hide();
		var ansColWidth = Number($('.col-answers', thisQuestion).attr('width').replace(/%/, ''));
		var newColWidth = (100-ansColWidth)/($('col.odd, col.even', thisQuestion).length-1);
		$('col.odd, col.even', thisQuestion).attr('width', newColWidth+'%');
 
		// Move the hidden text input into the array
		$('th.answertext:last', thisQuestion).append($('input[type="text"]', nextQuestion)).closest('tr').addClass('otherRow');
 
		// Initial "N/A" radio setting
		if($('.otherRow input:radio:checked', thisQuestion).length == 0) {
			$('.otherRow .na-column input:radio', thisQuestion).trigger('click');
		}
 
		// Some styling...
		$('input[type="text"]', thisQuestion).css({
			'width': '50%'
		});		
 
		// Handle the "Other" radios
		$('input[type="text"]', thisQuestion).on('keyup change',function(event){
			event.stopPropagation();
 
			if($.trim($(this).val()) == '') {
				$('.otherRow input:radio', thisQuestion).prop('checked',false);
				$('.otherRow .na-column input:radio', thisQuestion).click();
			}
			else {
				$('.otherRow .na-column input:radio', thisQuestion).prop('checked',false);
			}
		});	
	});
</script>

File Attachment:

File Name: limesurvey...9988.lss
File Size:20 KB
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: OMdev

Array Question with "Other" Answer 1 month 1 week ago #121917

  • OMdev
  • OMdev's Avatar
  • Offline
  • Gold Lime
  • Posts: 173
  • Thank you received: 8
  • Karma: 8
I am not getting emails when this thread updates. I am already subscribed to it and its in my favorite thread list.
Trivender Singh
Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
The administrator has disabled public write access.

Array Question with "Other" Answer 1 month 1 week ago #121918

  • jelo
  • jelo's Avatar
  • Offline
  • Platinum Lime
  • Posts: 691
  • Thank you received: 79
  • Karma: 23
I got a email about your post. And the last post before was 2 weeks ago.
Perhaps an issue on mailserver level.

But thanks for your post. I forgot to say "Thank you" to tpartner.
Shame on me. Have to reduce the threads I follow at the same time.
The administrator has disabled public write access.
The following user(s) said Thank You: OMdev

Array Question with "Other" Answer 1 month 1 week ago #121919

  • OMdev
  • OMdev's Avatar
  • Offline
  • Gold Lime
  • Posts: 173
  • Thank you received: 8
  • Karma: 8
Thanks ..Its fine now.. :) . Now I am getting emails ..
Trivender Singh
Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.161 seconds