Solved
Deselecting other checkboxes if one is selected
Suppose I have a checkbox style question - "What fruits do you like?" and the options are:
* Apples
* Bananas
* Oranges
* Unsure
I want to try and implement two functionalities:
1. In case the user selects "Unsure", then I'd want the other checkboxes to be deselected
2. If afterwards the user deselects "Unsure", then the selections made previously should reappear
I need to necessarily figure out a way to implement (1). (2) would be a nice-to-have, but not wholly needed. Follows is the code, wherein I tried to implement this:
jQuery("#QID10-4-label").click(function(){
if(jQuery("#QID10-4-label").hasClass("q-checked")){
//This will be implemented if the user has selected option 4
jQuery("#QID10-1-label").prop("q-checked", false);
jQuery("#QID10-2-label").prop("q-checked", false);
jQuery("#QID10-3-label").prop("q-checked", false);
} else {
//This will be implemented if the user has deselected option 4
//Ideally I'd want to be able to reselect those options which had been previously selected if any
}
});
Any help on this would be much appreciated.
Thanks!
Best answer by VirginiaM
@avikram you can actually do this without custom code. Write out the question, right click on the "Unsure" answer choice and choose "Make answer exclusive". See screenshot:!
View original
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.