Basics: Comparing Previous Two anwsers and hiding Question if they match | XM Community
Skip to main content
Hi All, I'm new to the Qualtrics API and trying to figure out the basics right now. I've used two previous posts to try and figure this out listed below:

https://www.qualtrics.com/community/discussion/579/javascript-basics - for function on accessing previous answers

https://www.qualtrics.com/community/discussion/2640/javascript-code-for-show-and-hide-information- for jQuery hide function



I can't seem to get anything to work and when I look up the Qualtrics API library it doesn't really help me understand how to use the functions. This is the code I've tried:



Qualtrics.SurveyEngine.addOnReady(function()

{



if ("${q://QID3/ChoiceGroup/SelectedChoices}" == "${q://QID9/ChoiceGroup/SelectedChoices}")

{ jQuery("#QID11").hide();}





}

I'm comparing questions 3 and 9, which are singular slide scales from 0-10 and then trying to hide 11 if they answer 3 and 9 the same way.
If QID3 and QID9 are single sliders, then your pipes are wrong. It should be:

```

Qualtrics.SurveyEngine.addOnReady(function() {

if("${q://QID3/ChoiceNumericEntryValue/1}" == "${q://QID9/ChoiceNumericEntryValue/1}") {

jQuery("#"+this.questionId).hide();

}

});

```

You should always pipe the value into your Question Text using "Piped Text..." then cut and paste it into your JavaScript.

Leave a Reply