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)
Page 1 / 1
It the question is skipped with Qualtrics display logic or skip logic, you can't do anything to it with JavaScript since it never gets sent to the browser.
If you are hiding your question with JavaScript, then you can still use `this.setChoiceValue(2,true);` in the question's JavaScript.
If you are hiding your question with JavaScript, then you can still use `this.setChoiceValue(2,true);` in the question's JavaScript.
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?
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?
> @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.
> 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.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.