How to hide a question after it is answered | XM Community
Skip to main content
Solved

How to hide a question after it is answered

  • November 5, 2023
  • 3 replies
  • 410 views

Forum|alt.badge.img+1

I am trying to set up a study within Qualtrics where participants can only see one question at a time. So, I need question 1 to disappear after it is answered and question 2 to appear. Then, I need question 2 to disappear after it is answered and question 3 to appear, etc. 

 

I cannot separate them with page breaks because I need there to be a 2-minute time limit and the timer question only works at the page level and not the block level. I know with JavaScript you can implement a block level timer; however, this appears to be limited to “click next” at time 0, which would keep participants in the same block if there were questions remaining versus advancing them to the next block.

 

Thanks for any help that you can provide!

Best answer by Tom_1842

The below works okay on my end. Create 3 Text Entry questions and add in-page display logic to the second and third questions so that they only display if the previous text entry is not empty. Then, add the below to each of the question's JS in the OnReady section. It will hide the text entry question once the input is unfocused but only if a value exists.

var quest = document.getElementById(this.questionId);
var input = document.getElementById("QR~"+this.questionId);

input.onblur = function(event) {
if (input.value !== "") {
quest.style.display = 'none';
}
}

 

3 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • 654 replies
  • November 6, 2023

If we only have single select question and no text entry or any option with text entry, then we can use below code:

Qualtrics.SurveyEngine.addOnload(function ()
{
this.questionclick = function(event,element)
{
if (element.type == 'radio')
{
jQuery("#"+this.questionId).hide();
}
}
});

 


Forum|alt.badge.img+1
  • Author
  • 1 reply
  • November 6, 2023

Thanks for your reply Shashi!

Participants will be completing a letter decode task, so there will be text entries. I’ve attached an image below. My hope is that there is a way to make “Decode: 102” disappear after typing a letter in the text entry box. Making “Decode: 653” appear after “Decode:102” is answered is straightforward. I just can include display logic if “Decode: 102” equals not empty. My thought was that there may be a way to code it that “Decode: 102” disappears once they click on “Decode: 653”. Given that “Decode: 653” cannot show unless there is an answer in “Decode: 102”, the decodes will always be answered in order.

 

 


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • Answer
  • November 6, 2023

The below works okay on my end. Create 3 Text Entry questions and add in-page display logic to the second and third questions so that they only display if the previous text entry is not empty. Then, add the below to each of the question's JS in the OnReady section. It will hide the text entry question once the input is unfocused but only if a value exists.

var quest = document.getElementById(this.questionId);
var input = document.getElementById("QR~"+this.questionId);

input.onblur = function(event) {
if (input.value !== "") {
quest.style.display = 'none';
}
}