- Posts: 28
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Maximun answers var maxAnswers = 3; // Identify this question var thisQuestion = $('#question{QID}'); function checkMax() { $('input.checkbox', thisQuestion).prop('disabled', false); if($('input.checkbox:checked', thisQuestion).length >= maxAnswers) { $('input.checkbox', thisQuestion).not(':checked').prop('disabled', true); } } // Initial checkbox states checkMax(); // Listener on the checkboxes $('input.checkbox', thisQuestion).change(function(e) { checkMax(); }); // Remove any "disabled" properties before submitting $('#movenextbtn, #movesubmitbtn').bind('click', function () { $('input.checkbox', thisQuestion).prop('disabled', false); }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Uncheck all excluded items $('div.question-item:last input.checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { $('input.checkbox', thisQuestion).not($(this)).each(function(i) { $(this).prop('checked', false); $(this).nextAll('input:hidden:eq(0)').attr('value', ''); }); } }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { keepPos('{SGQ}',['6|6','7|7']) // keepPos('{SGQ}',['code|position','code|position']) }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var qID = {QID}; var thisQuestion = $('#question'+qID); // Define the sub-question codes to be placed last var lastItems = [ 'SQ005','SQ008']; // Loop through those sub-question codes $.each(lastItems, function(i, val) { // Move that item to the end of the list // Multi-choice question if($(thisQuestion).hasClass('multiple-opt')) { $('.question-item[id$=X'+qID+val+']', thisQuestion).parent().appendTo($('.subquestion-list', thisQuestion)); } // Array question if($(thisQuestion).hasClass('array-flexible-row')) { $('.answers-list[id$=X'+qID+val+']', thisQuestion).appendTo($('table.subquestion-list', thisQuestion)); } }); }); </script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Uncheck all excluded items $('div.question-item:last input.checkbox', thisQuestion).on('change', function(e) { if($(this).is(':checked')) { $('input.checkbox', thisQuestion).not($(this)).each(function(i) { $(this).prop('checked', false); $(this).nextAll('input:hidden:eq(0)').attr('value', ''); }); } }); }); </script>