JavaScript stops working when title is published

shiggins-9138 Community Member Posts: 9

As part of a Quiz, I'm trying to limit the maximum number of checkbox selections in a Multiple Response question using JavaScript. I've implemented the function outlined by Sergey Snegirev in Pg1 of his four-part tutorial...

if ($('input:checked').length == 3) {
$('input:not(:checked)').attr('disabled', true);
} else {
$('input').attr('disabled', false);

...which runs fine in the Lectora Online single page preview (checkboxes disabled at a count of 3 and popups show the correct numbers), but fails once the project is published. The popups still work so the JS is running, but it's failing to work out how many boxes been selected (popups always show a value of 0).

NOTE: I've implemented this JS function on each button rather than at page level as I've overridden the default checkbox image, but it works just fine within Lectora. I've also followed Sergey's tutorial on a blank project to test from scratch and I'm still having the same problem. I've seen this happen on other JS functions I've tested in the past.

What am I missing?

Thanks in advance