- Posts: 4
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
A | Always | Sometimes | Never |
B | Always | Sometimes | Never |
C | Always | Sometimes | Never |
In that case, I would do this with a combination of an array and a hidden multiple-choice question.But I have got about 15 questions in array. It could be a little bit annoying to have 15 more questions if respondent answer "Never" in all questions in array.
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var qID = {QID}; var thisQuestion = $('#question'+qID); var nextID = $(thisQuestion).nextAll('.multiple-opt:eq(0)').attr('id').replace(/question/, ''); var nextQuestion = $('#question'+nextID); // Assign column-specific classes $('table.subquestion-list tr', thisQuestion).each(function(i) { $('> *:gt(0)', this).each(function(i){ $(this).addClass('column-'+(i+1)); }); }); // Loop through the array rows $('tr.answers-list', thisQuestion).each(function(i) { var thisCode = $(this).attr('id').split('X'+qID)[1]; // Remove the radios from the last column $('.answer-item:last *', this).remove(); // Insert the checkboxes $('.answer-item:last', this).removeClass('radio').append($('.answer-item[id$="X'+nextID+thisCode+'"]', nextQuestion)); }); // A function to handle the last-column label function handleLastlabel() { if($('.column-3 input.radio:checked', thisQuestion).length == 0) { $('thead .column-4', thisQuestion).css({ 'opacity': 0.35 }); } else { $('thead .column-4', thisQuestion).css({ 'opacity': 1 }); } } handleLastlabel(); $('input.radio', thisQuestion).on('click', function(e) { handleLastlabel(); }); // Some clean-up stuff if($(window).width() > 800) { $('.answer-item:last-child .label-text', thisQuestion).hide(); } $(window).resize(function() { if($(window).width() > 800) { $('.answer-item:last-child .label-text', thisQuestion).hide(); } else { $('.answer-item:last-child .label-text', thisQuestion).show(); } }); $('.answer-item:last-child .checkbox-item', thisQuestion).css({ 'padding': 0, 'margin': 0 }); }); </script>