I have this code that is to select three options in a multiple choice question, but I noticed that it applies to a WHOLE PAGE instead of just the specific question. What can I do to chaange this code so that it is only for a specific question?
this.questionclick = function(event,element){
var selectedchoice=this.getSelectedChoices();
if(selectedchoice.length==3){
jQuery("#"+ this.questionId +" input:checkbox:not(:checked)" ).attr("disabled", true);
}else{
jQuery("#"+ this.questionId +" input:checkbox:not(:checked)" ).attr("disabled", false);
var lastChecked;
var $checks = jQuery('input:checkbox').click(function(e) {
var numChecked = $checks.filter(':checked').length;
if (numChecked > 3) {
lastChecked.checked = false;
}
lastChecked = this;
});
}
}
Thanks!
Best answer by PeeyushBansal
View original