Deselecting other checkboxes if one is selected | XM Community
Solved

Deselecting other checkboxes if one is selected

  • 19 September 2019
  • 3 replies
  • 140 views

Userlevel 1
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!
icon

Best answer by VirginiaM 19 September 2019, 14:35

View original

3 replies

Userlevel 6
Badge +45
@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:!
Userlevel 1
Sorry for the late reply. Thanks! This works.
Badge

Hello, I know this was a while ago, but… 

I made a date picker out of multiple choice questions (question is the day, choices are the hours) and this Q&A was very helpful, given participants can now choose only one option per day, but I want to make it one question per block. Is this possible?

Leave a Reply