- Posts: 79
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var qID = '{QID}'; var thisQuestion = $('#question'+qID); // Assign column-specific attributes and classnames $('tr.subquestion-list', thisQuestion).each(function(i) { $('> *', this).each(function(i) { $(this).attr('data-column', i); }); }); $('tr.subquestion-list', thisQuestion).slice(-2).find('td.answer-item').addClass('exclusive-item'); // A function to un-check boxes function resetCheckbox(thisItem) { $(':hidden', thisItem).val(''); $(':checkbox', thisItem).prop('checked', false).trigger('change'); } // Listener on the checkboxes $(':checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { var thisItem = $(this).closest('.answer-item'); var thisColumn = $(thisItem).attr('data-column'); var items = $('td.answer-item[data-column="'+thisColumn+'"].exclusive-item', thisQuestion); if($(thisItem).hasClass('exclusive-item')) { items = $('td.answer-item[data-column="'+thisColumn+'"]', thisQuestion).not(thisItem); } $.each(items, function(i, el) { resetCheckbox(el); }); } }); }); </script>