Hiding question with js | XM Community
Skip to main content

Hello, 

I have a slideshow with 5 images that participants click through. After they have clicked through all 5 images, I want

  1. the Next button to appear (hidden before)
  2. a question to get hidden (which was visible as part of the instructions to the slideshow before)

I have the following code, that does 1. but not 2. Any thoughts on what I am doing wrong?

viewedSlides.add(slideIndex);
      if (viewedSlides.size === x.length) {
        Qualtrics.SurveyEngine.setEmbeddedData("allSlidesViewed", "true");
          jQuery("#NextButton").show();
          jQuery("#QID80").hide();
          
      }

Please recheck the question id for the instruction question.


Thanks ​@Shashi. That was my first hunch too, but the QID is correct. It’s a bit of a mystery. 


@Shashi I think I may have figured out what is causing the code to not work.

My question and slideshow is part of a loop. Each loop, they see a slideshow and the same instruction. Maybe I need to add an indicator for the loop in addition to the QID? Would you know how I can code this?


@pb7,

You can do it based on where the instruction question is on the page or relative to the slide show question. For example, if the instructions are the first question on the page:

jQuery(".QuestionOuter").first().hide();

 


Thanks ​@TomG! It worked!


Leave a Reply