Hide one column of a side-by-side question based on a previous question | XM Community
Solved

Hide one column of a side-by-side question based on a previous question

  • 12 January 2021
  • 4 replies
  • 120 views

Userlevel 2
Badge +2

New to JS (and to Qualtrics too).
We have a side-by-side question (Q3) with several columns: one drop-down, 2 text (which it calls one column) , one radio buttons
image.png

We need to hide 2 or 3 of the columns IF they responded with a zero or a blank to a previous question (Q1).
image.png
Any help greatly appreciated!



icon

Best answer by treimt 14 January 2021, 19:45

View original

4 replies

Userlevel 7
Badge +21

If you split up text entry question into two, then you can use the code below, by just changing the QID and choice ids.
Qualtrics.SurveyEngine.addOnReady(function(){

c2 = "${q://QID14/ChoiceTextEntryValue/1}";
c2 = c2.replaceAll(/\\,\\s/gm,"");
if(c2 == 0){
this.getChoiceContainer().querySelectorAll(".SBS2").forEach(item => item.remove());
}

c3 = "${q://QID14/ChoiceTextEntryValue/2}";
c3 = c3.replaceAll(/\\,\\s/gm,"");
if(c3 == 0){
this.getChoiceContainer().querySelectorAll(".SBS3").forEach(item => item.remove());
}
});

Userlevel 2
Badge +2

Thanks for the answer. As I said I am new to JS.
When I inspect the preview to find the QID it seems to be:
#QR\\~ID8\\#1\\~1\\~1\\~TEXT
How do I translate this into the format of your:
"${q://QID14/ChoiceTextEntryValue/1}"
Thanks

Userlevel 7
Badge +21

I haven't seen anything like that before. What kind of a question is it?
Don't inspect, use piped text to figure out the replacement.
With your current setup, SBS2 corresponds to the "Number of question" and SBS3 to the yes/no question. So, you'll have to split it into two questions.

Userlevel 2
Badge +2

Perfect. Thanks!!!

Leave a Reply