Dynamically Hide a Question Based on User Response | XM Community
Question

Dynamically Hide a Question Based on User Response

  • 28 September 2020
  • 4 replies
  • 317 views

As far as I can tell, Qualtrics does not provide display logic to remove a question or answer on the same page in which a response is made. In other words, I can hide an question so that it doesn't appear until a particular response is made, but I cannot remove a question after a particular response is made. It looks like I will need javascript to make this happen. I haven't written java in years, and I've never inserted java into another gui. In the survey, participants will read a passage, then click finished after reading, and click show questions when ready to take the test. On some blocks, they will have no option to cheat (the question will disappear when they click show questions). On other cheat blocks, the questions will "accidentally" appear when they click "finished" and the passage is still displayed. If they click "show questions", the passage would then disappear. Here is what I would like to happen.
Question 1: Text/Graphic Type - A passage participants must read.
Question 2: Multiple Choice Type (Multiple Select) - Options are Finished and Show Questions.
*On no cheat blocks, after clicking "Show Questions", I'd like Question 1 to disappear and questions 3-5 would appear without Question 1 present. Put it on a new page, you might say, that's super easy. However, on other blocks I want to give them the option to cheat. In other words, I want Questions 3-5 to be displayed when they click "Finished" (instead of "show questions) and I want Question 1 to remain on the same page. That way they can use the passage to answer the questions within the same page. I don't want the cheat option to be very obvious, so I don't want them to have the questions on another page on some blocks and the same page on other blocks, that makes it very obvious that something is different about those questions.
Question 3-5: Displayed only once "Show Questions" is clicked in Question 2 using display logic in the no cheat blocks and once "Finished" is clicked on cheat blocks.

Any help/advice is appreciated!


4 replies

Userlevel 7
Badge +27

Yes, you can use JS to show and hide questions as needed. Add JS to your second question (Finished/Show Questions).
Your first question on the page will be:
var q1 = jQuery(".QuestionOuter:first");
Assuming questions 2 through 5 are multiple choice, questions 3-5 would be:
var q3to5 = jQuery(".QuestionOuter.MC:not(:first)");
Then you can do things like:
q1.hide();
q3to5.show();

Userlevel 3
Badge +3

Hello @TomG 

I hope you are doing well !

 

It seems like I want to do something similar as @Kenneth in my survey  : 

Is there anyway I can make a question appear as the respondent is answering the survey, to give you an exemple (see question below) if a person rates 1 star I want a text entry question to appear on this same page (see black arrow) asking “why ?” 

 

Many thanks 

 

Userlevel 7
Badge +27

Yes, if you can’t use in-page display logic, you can use JS. Set up an event handler to show/hide when the star value changes.

Userlevel 3
Badge +3

Hello @TomG thanks for your answer :)

Leave a Reply