Groups of choices following the same display logic | XM Community
Skip to main content
Question

Groups of choices following the same display logic


HenrikeS
Level 2 ●●
Forum|alt.badge.img+2

Hi everyone!

Maybe I'm just on the tube (as we say in Germany) but I can’t find a solution for this:

I have a multiple choice question (B) with 60 choices:

  • 10 of these should be shown if in the preceding question A choice 1 is selected.
  • 12 of these should be shown if in the preceding question A choice 2 is selected.
  • 9 of these should be shown if in the preceding question A choice 1 is selected.
  • ...

That means: 10/12/9/... should be displayed following the same condition respectively.

Of course I know how to set a display logic for each of the choices, but it is too time consuming to do this for each of them. So I would like to  “subsume” 10/12/9/.. choices under one display logic.

Can you help me with this?

:) h.

3 replies

Forum|alt.badge.img+16

Hi ​@HenrikeS ,

 

It has been some time since this question was posted, so you may not require this suggestion.

I came up with the code below while taking reference from some past threads.

Qualtrics.SurveyEngine.addOnload(function()
{
	/*Place your JavaScript here to run when the page loads*/
	/*Hide all option at the start, using 31 here as your example is 10+12+9*/
	for (let i = 1; i <= 31; i++) {
  			jQuery("#"+this.questionId+" input[choiceid="+ i+ "]").closest("li").hide();
		}
	/* Change QID*/
	let abovechoice="${q://QID22/ChoiceGroup/SelectedChoices}";

	/* This is the first group, change the number 10 if required*/
	if (abovechoice==="1") {
		for (let i = 1; i <= 10; i++) {
  			jQuery("#"+this.questionId+" input[choiceid="+ i+ "]").closest("li").show();
		}
	}

	/* This is the second group, change the number 11 and 22 if required*/	
	 else if (abovechoice==="2"){
		for (let i = 11; i <= 22; i++) {
  			jQuery("#"+this.questionId+" input[choiceid="+ i+ "]").closest("li").show();
		}
	}
	/* Copy the second group and paste here if you need more groups.

	/* This is the last group, change the number 23 and 31 if required*/
	 else {
		for (let i = 23; i <= 31; i++) {
  			jQuery("#"+this.questionId+" input[choiceid="+ i+ "]").closest("li").show();
		}
	};
});

Hope it helps.


vgayraud
QPN Level 5 ●●●●●
Forum|alt.badge.img+48
  • QPN Level 5 ●●●●●
  • 362 replies
  • March 7, 2025

When I have time consuming logic to program, I tend to use the API.

In your case, set the display logic on one choice to have an example and then use the get question and update question API to modify your question.

See https://api.qualtrics.com/1ebd0bb7008f8-get-question and https://api.qualtrics.com/00d49b25519bb-update-question


HenrikeS
Level 2 ●●
Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 17 replies
  • March 10, 2025

@Chee Heng_SZ

@vgayraud

Thank you so much for your replies!

I will test them both and then come back to this thread.

:) h.


Leave a Reply