Hi,
I was wondering if someone knows an update for the code in Limesurvey 3. I can't seem to get it to work.
I figured the following part doesn't work:
Code:
$('input.checkbox', thisQuestion).change(function(e) {
checkMax();
});
To test, I've added an alert:
Code:
$('input.checkbox', thisQuestion).change(function(e) {
alert('hello');
checkMax();
});
Whenever i enable or disable a checkbox there's no alert.
TO make sure javascript works i added the alert at the beginning, and that shows me an alert when the page loads:
Code:
<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>