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

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!

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();
}
}
});

 


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.

 

 


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';
}
}

 


Leave a Reply