- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).nextAll('.array-multi-flexi:eq(0)'); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable and un-check the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionRow).prop('disabled', false); $('input.checkbox', nextQuestionCell).prop('checked', false).prop('disabled', true); $('input:hidden', nextQuestionCell).attr('value', ''); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).nextAll('.array-multi-flexi:eq(0)'); // Initial states // Loop through all clicked radios $('input.radio:checked', thisQuestion).each(function(i) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionCell).prop('disabled', true); }); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable and un-check the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionRow).prop('disabled', false); $('input.checkbox', nextQuestionCell).prop('checked', false).prop('disabled', true); $('input:hidden', nextQuestionCell).attr('value', ''); }); }); </script>