- Posts: 18
- 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(){ var thisQuestion = $('#question{QID}'); // Add column and row specific classes $('tr.subquestion-list', thisQuestion).each(function(i) { var rowIndex = i; $('th, td', this).each(function(i) { $(this).addClass('column-'+i+' row-'+rowIndex).attr('data-column', i).attr('data-row', rowIndex); }); }); // Add some classes to the checkbox cells $('tr.subquestion-list .answer-item:last-child', thisQuestion).addClass('exclusive-item row-exclusive'); $('tr.subquestion-list:last .answer-item', thisQuestion).addClass('exclusive-item column-exclusive'); // A listener on the checkboxes $('.answer-item input[type="checkbox"]', thisQuestion).change(function (event) { handleExclusive($(this).closest('.answer-item')); }); function handleExclusive(thisCell) { var thisCheckBox = $(':checkbox', thisCell); if(thisCheckBox.is(':checked')) { var thisRow = $(thisCell).attr('data-row'); var thisColumn = $(thisCell).attr('data-column'); // Define items to be unchecked excludeCells = $('.exclusive-item[data-column="'+thisColumn+'"], .exclusive-item[data-row="'+thisRow+'"]'); if(thisCell.hasClass('row-exclusive')) { excludeCells = $('.answer-item[data-row="'+thisRow+'"]').not(thisCell); } if(thisCell.hasClass('column-exclusive')) { excludeCells = $('.answer-item[data-column="'+thisColumn+'"]').not(thisCell); } // Uncheck those items $(excludeCells).each(function(i) { $('input:hidden', this).val(''); $(':checkbox', this).prop('checked', false).trigger('change'); }); } } // Remove checkbox in last row, last column $('tr.subquestion-list:last .answer-item:last-child *', thisQuestion).remove(); }); </script>
sum(Q1_SQ001_SQ00C,Q1_SQ001_SQ00D,Q1_SQ002_SQ00C,Q1_SQ002_SQ00D,Q1_SQ003_SQ00C,Q1_SQ003_SQ00D)=
unless there is a way to sum all the values for the last two columns ...