- Posts: 136
- Thank you received: 4
Ask the community, share ideas, and connect with other LimeSurvey users!
- forums.limesurvey.org/forum/can-i-do-thi...-all-others&start=15I searched the forum and there was no answer to the column.
<script type="text/javascript" charset="utf-8"> $(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:last td.answer-item', thisQuestion).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+'"]:not(.exclusive-item)', thisQuestion); } $.each(items, function(i, el) { resetCheckbox(el); }); } }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // The subquestion code to place in the last position var fixedCode = 'A20'; // Identify this question var q1ID = {QID}; var thisQuestion = $('#question'+q1ID); // Move the "fixed" row to the end $('table.subquestion-list tbody:last', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]')); // Fix up the array row background colours $('tr.answers-list', thisQuestion).each(function(i){ $(this).removeClass('array1 array2').addClass('array'+(2-(i%2))); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(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:last td.answer-item', thisQuestion).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+'"]:not(.exclusive-item)', thisQuestion); } $.each(items, function(i, el) { resetCheckbox(el); }); } }); }); </script>