- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
$('input.checkbox', thisQuestion).change(function(e) { checkMax(); });
$('input.checkbox', thisQuestion).change(function(e) { alert('hello'); checkMax(); });
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { alert('hello'); // 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>
function checkMax() { $('input[type="checkbox"]', thisQuestion).prop('disabled', false); if($("input:checked", thisQuestion).length >= maxAnswers) { $('input[type="checkbox"]', thisQuestion).not(':checked').prop('disabled', true); } }
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Maximun answers var maxAnswers = 2; // Identify this question var thisQuestion = $('#question{QID}'); function checkMax() { $('input[type="checkbox"]', thisQuestion).prop('disabled', false); if($("input:checked", thisQuestion).length >= maxAnswers) { $('input[type="checkbox"]', thisQuestion).not(':checked').prop('disabled', true); } } // Initial checkbox states checkMax(); // Listener on the checkboxes $('input[type="checkbox"]', thisQuestion).on('change', function(e) { checkMax(); }); // Remove any "disabled" properties before submitting $('#movenextbtn, #movesubmitbtn').bind('click', function () { $('input[type="checkbox"]', thisQuestion).prop('disabled', false); }); }); </script>
$('#limesurvey').on('submit', function(e) {
Isn't that a back-step in development? No easy way to check if back or next were clicked, right?tpartner wrote: I think you will also want to change the submit listener as there is no #movenextbtn element anymore.
Then I got you wrong, I got the impression that it would be no longer possible in LS3.tpartner wrote: Yes, you could target the buttons