Automatically selecting one option based on previous selections | XM Community
Skip to main content
Solved

Automatically selecting one option based on previous selections

  • June 15, 2023
  • 1 reply
  • 97 views

MattiasM
Level 5 ●●●●●
Forum|alt.badge.img+63

Hello and good afternoon from a cloudy Sweden!

If I have a multiselect question with three options in it, 1, 2 and 3. 

How can I set it up so that if a person selects both 1 and 2, then 3 is automatically selected? 

 

Thanks in advance

-Mattias

 

Best answer by ArunDubey

Please refer this. with this scenario, if respondent will select option 1 and 2, option 3 will be auto selecred. If respondent will remove check from option 1 or 2 the option 3 will be unchecked. respodent cannot select or unselect option 3.

 

jQuery(":checkbox").click(function(){
if(jQuery(".Selection:eq(0) input").is(":checked") && jQuery(".Selection:eq(1) input").is(":checked")){
jQuery(".Selection:eq(2) input").prop('checked',true);
}
if(jQuery(".Selection:eq(0) input").prop('checked')==false || jQuery(".Selection:eq(1) input").prop('checked')==false){
jQuery(".Selection:eq(2) input").prop('checked',false);
}
});

 

1 reply

ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • Answer
  • June 15, 2023

Please refer this. with this scenario, if respondent will select option 1 and 2, option 3 will be auto selecred. If respondent will remove check from option 1 or 2 the option 3 will be unchecked. respodent cannot select or unselect option 3.

 

jQuery(":checkbox").click(function(){
if(jQuery(".Selection:eq(0) input").is(":checked") && jQuery(".Selection:eq(1) input").is(":checked")){
jQuery(".Selection:eq(2) input").prop('checked',true);
}
if(jQuery(".Selection:eq(0) input").prop('checked')==false || jQuery(".Selection:eq(1) input").prop('checked')==false){
jQuery(".Selection:eq(2) input").prop('checked',false);
}
});