Welcome, Guest
Username: Password: Remember me

TOPIC: Display number of rows in array question based on previous numerical input

Display number of rows in array question based on previous numerical input 1 month 1 week ago #122880

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5095
  • Thank you received: 1046
  • Karma: 440
Hmm...it seems that the built-in JS for enforcing numerics is conflicting in IE.

If you don't want to use short-text, how about a list (dropdown)?

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		// Identify the questions
		var q1ID = '{QID}';
		var q1 = $('#question'+q1ID+'');
		var q2 = $(q1).nextAll('.array-multi-flexi-text:eq(0)'); 
		var q2ID = $(q2).attr('id').split('question')[1];
 
		// Initial row handling
		handleRows($('.answer-item select', q1));
 
		// Listener on the numeric input
		$('.answer-item select', q1).change(function() {
			handleRows(this);
		});
 
		function handleRows(el) {
			var numRows = $(el).val();
			$('tr.subquestion-list', q2).hide();
			$('tr.subquestion-list', q2).each(function(i){
				if(i >= numRows) {
					$('input[type="text"], select', this).val('');
				}
				else {
					$(this).show();
				}
			})
		}
	});
</script>

File Attachment:

File Name: limesurvey...7(2).lss
File Size:22 KB

This message has an attachment file.
Please log in or register to see it.

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.
Last Edit: 1 month 1 week ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.126 seconds