Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all articles
Browse latest Browse all 17529

Answer options based on previous question - by: tpartner

$
0
0
This will work in 2.5x:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// The Q2 options corresponding to the Q1 options		
		teacherLists = {
			C1 : 'T1,T3,T5',
			C2 : 'T1,T2,T3,T4',
			C3 : 'T2,T3,T4,T5',
			C4 : 'T1,T4,T6'
		};
 
		// Identify this question
		var thisQuestion = $('#question{QID}')
 
		// The checked option in Q1
		var q1Ans = '{Q1}';
 
		// Hide all of the teachers
		$('.answer-item', thisQuestion).hide();
 
		// Now show the appropriate ones
		$(teacherLists[q1Ans].split(',')).each(function(i){
			$('input.radio[id$="'+{QID}+this+'"]').closest('.answer-item').show();
		});
 
		// Uncheck all hidden radios (in case page has been seen before)
		$('.answer-item:hidden input.radio', thisQuestion).prop('checked', false);
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey_survey_361532_2017-01-30.lss
File Size: 16 KB

Viewing all articles
Browse latest Browse all 17529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>