I’m using the following code to see if a checkbox is checked and then setting it to true if it is:
$q2choice1.on('click', function() {
$(this).data('clicked', true);
});
Then running a function to display specific messages depending on which checkbox is clicked:
$q1submit_button.on('click', function() {
if($q1choice35.data('clicked')) {
showMsg();
} else if($q1choice41.data('clicked')) {
showMsg();
} else if($q1choice52.data('clicked')) {
showMsg();
} else if($q1choice64.data('clicked')) {
$q1correct.show();
$q1error.hide();
}
$q1next_button.show();
$q1submit_button.hide();
});
The problem is, that if someone clicks on a checkbox choice, it registers as true and then if they change their minds and choose another checkbox, another instance is set to true. How can I modify the code such that there can only be one true condition set?