- Posts: 10248
- Thank you received: 3646
Ask the community, share ideas, and connect with other LimeSurvey users!
<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 $('li[id^="javatbd"]', thisQuestion).hide(); // Now show the appropriate ones $(teacherLists[q1Ans].split(',')).each(function(i){ $('input.radio[id$="'+{QID}+this+'"]').closest('li').show(); }); // Uncheck all hidden radios (in case page has been seen before) $('li[id^="javatbd"]:hidden input.radio', thisQuestion).prop('checked', false); }); </script>
<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>
<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){ $('.answer-item[id$="'+{QID}+this+'"]').show(); }); // Uncheck all hidden radios (in case page has been seen before) $('.answer-item:hidden input.radio', thisQuestion).prop('checked', false); }); </script>