- Posts: 3
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}') // Add some classes to the checkbox cells $('td.checkbox-item', thisQuestion).addClass('normal-item'); $('tr.subquestion-list', thisQuestion).each(function(i) { $('.normal-item:last', this).removeClass('normal-item').addClass('exclusive-item') }); // A listener on the checkboxes $('input[type="checkbox"]', thisQuestion).on('change', function (event) { handleCheckboxes($(this)); }); function handleCheckboxes(thisInput) { var thisCell = $(thisInput).closest('td'); var thisRow = $(thisCell).closest('tr'); $('input[type="checkbox"]', thisRow).prop('disabled', false); $('td', thisRow).closest('td').removeClass('checked-item'); $('input[type="checkbox"]:checked', thisRow).closest('td').addClass('checked-item'); // Exclusive item if($('.exclusive-item input[type="checkbox"]:eq(0)', thisRow).is(':checked')) { $('.normal-item input[type="hidden"]', thisRow).val(''); $('.normal-item input[type="checkbox"]', thisRow).prop('checked', false).prop('disabled', true); } else { $('.exclusive-item input[type="hidden"]', thisRow).val(''); $('.exclusive-item input[type="checkbox"]', thisRow).prop('checked', false); } // Max 3 answers per row if($('input[type="checkbox"]:checked', thisRow).length == 3) { $('td:not(.exclusive-item):not(.checked-item)', thisRow).find('input[type="checkbox"]').prop('disabled', true); } // Check conditions (relevance) $('td.checkbox-item', thisRow).each(function(i) { var thisValue = ''; if($('input[type="checkbox"]', this).is(':checked')) { thisValue = 1; } var thisSGQA = $('input[type="checkbox"]', this).attr('id').replace(/cbox_/, ''); $('input[type="hidden"]', this).attr('value', thisValue); fixnum_checkconditions(thisValue, thisSGQA, 'hidden'); }); } }); </script>
Please Log in to join the conversation.