Many thanks in advance to anybody who may be able to assist.
I’m trying to create mutual exclusivity between two checkboxes (i.e. when one of these check boxes is checked, the other is automatically unchecked). I have two different applications:
- Scenario 1: The two checkboxes that are contained in the same longer list of checkboxes (seven checkboxes all up, but only two within this list are to be mutually exclusive).
- Scenario 2: The two checkboxes are contained in separate lists of checkboxes (but on the same survey question page).
any assistance greatly appreciated.
many thanks for your help. This is spot on and serves both scenarios properly. There is one little issue that I will mention in GitHub as well as here. The issue is true for both scenarios I described above.
In combination with a “none of the above” checkbox in SurveyGizmo, if a user checks any of the exclusive checkbox group(s) and then checks the “none of the above” checkbox followed by unchecking the “none of the above” checkbox (in an effort to re-answer the question), the script won’t restore to the original unanswered state – instead if makes all checkboxes in exclusive groups unanswerable. That’s a confusing (and low probability) use-case I know!
To replicate try the following:
- Then check the “none-of-the-above” option
- Now uncheck the “none-of-the-above” option
- This should result in the disabling of all grouped exclusive checkboxes that were previously checked.
I tried adding the exclusive group classes (
<i class="ns-exclusive-GROUP"></i>) to the “none-of-the-above” option. This helped for scenario 1 where the mutually exclusive group is within the same list of checkboxes, but it didn’t help scenario 2 where I need to ensure contextual availability of another checkbox in a different list.
The only reason for ensuring this robustness is for survey respondents who change their mind quite a bit when answering the two questions for which the script you wrote will be used.
Try this out for size:
Hey Nate. Thanks. Will check this out and report back.