Hiding question with js | XM Community
Skip to main content
Solved

Hiding question with js

  • December 2, 2024
  • 5 replies
  • 75 views

Forum|alt.badge.img+6
  • Level 2 ●●
  • 19 replies

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

Best answer by TomG

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

 

View original

5 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • December 3, 2024

Please recheck the question id for the instruction question.


Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • 19 replies
  • December 3, 2024

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


Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • 19 replies
  • December 5, 2024

@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?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5919 replies
  • Answer
  • December 5, 2024

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

 


Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • 19 replies
  • December 5, 2024

Thanks ​@TomG! It worked!


Leave a Reply