About MC question type | XM Community
Skip to main content
Solved

About MC question type

  • May 31, 2023
  • 3 replies
  • 43 views

Forum|alt.badge.img+4

In Qualtrics MC question type and I have set 5 answers for the question, could i set the first 4 answers in mutliple answers and when user choose the 5th one, it will clear the previous 4 choices..

For example, if i have setup the following

  1. Choose a number(s):

A1: 1

A2: 2

A3: 3

A4: 4

A5: none

 

For A1-4, user could multple select the answers. But when choosing A5, it will clear the previous choices in the survey.

How to do that? I have used the below javascript on custom validation of the question but seems wont work.

if (this.getSelectedChoices().length > 0 && this.getSelectedChoices().indexOf(4) > -1) {
this.clearChoices();
}

Best answer by ArunDubey

You should make none as exclusive option so while checking this all the other options will be unchecked by itself.

 

 

 

There is no need for JS for that. use system default option.

If you want to make A4 as SELECT ALL option and A5 as SELECT NONE. then you can use JS for A4 to select ALL, so if anyone will click on A4, A1 to A3 will be selected by itself.

 

jQuery("li:nth-last-child(2) input:checkbox").click(function(){
if(jQuery("li:nth-last-child(2) input:checkbox").is(":checked")){
jQuery("li:not(:nth-last-child(2)) input:checkbox").prop("checked",true);
jQuery("li:last-child input:checkbox").prop("checked",false);
}
if(!jQuery("li:nth-last-child(2) input:checkbox").is(":checked")){
jQuery("li:not(:nth-last-child(2)) input:checkbox").prop("checked",false);
jQuery("li:last-child input:checkbox").prop("checked",false);
}
});

 

3 replies

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

You should make none as exclusive option so while checking this all the other options will be unchecked by itself.

 

 

 

There is no need for JS for that. use system default option.

If you want to make A4 as SELECT ALL option and A5 as SELECT NONE. then you can use JS for A4 to select ALL, so if anyone will click on A4, A1 to A3 will be selected by itself.

 

jQuery("li:nth-last-child(2) input:checkbox").click(function(){
if(jQuery("li:nth-last-child(2) input:checkbox").is(":checked")){
jQuery("li:not(:nth-last-child(2)) input:checkbox").prop("checked",true);
jQuery("li:last-child input:checkbox").prop("checked",false);
}
if(!jQuery("li:nth-last-child(2) input:checkbox").is(":checked")){
jQuery("li:not(:nth-last-child(2)) input:checkbox").prop("checked",false);
jQuery("li:last-child input:checkbox").prop("checked",false);
}
});

 


Forum|alt.badge.img+4
  • Author
  • May 31, 2023

Hi Arun,

Thank you so much for your reply. it works.

Regards,

Alex

 


ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • May 31, 2023

Great, Good luck @alexwan !