Solved
Javascript Basics

How do you say "set code 2 of QID123 (multi) to be true/selected" in JavaScript? I know that you can use "this" to refer to the current question (see below), but how do you refer to QID123 if it's not the current question?
this.setChoiceValue(2,true);
(The reason I'm not adding this JavaScript to QID123 is because it's skipped)
Best answer by TomG
> @TriciaB said:
> Thanks. I was planning to use the Javascript in a separate (displayed) question, which is why I need to know how to refer to QID123 from another question.
>
> How would I hide QID123 using JavaScript? And does this mean it's not possible to refer to a different question than the one you're currently on?
You can hide a question like this:
```
jQuery("#"+this.questionId).hide();
```
As for referring to a different question, you can refer to the html elements in another question. However, there isn't an easy way to refer to the another question's Qualtrics question object (i.e., "this"). So, if you want to set values in another question you have to do it by manipulating the html elements instead of through the Qualtrics Question API.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.