Solved
Javascript Basics

Hello
Can anyone help me understand how to use JavaScript within Qualtrics? I'm trying to say "If QID1=2 then set QID2=2", but I can't work out how to write the "QID1=2" part. This is what I have so far, but how do I refer to QID1 from within QID2? They are both Multiple Choice.
[Within QID2]
Qualtrics.SurveyEngine.addOnload(function()
{
if ( ??? getChoiceValue(2) == true)
{this.setChoiceValue(2, true)}
});
I've been looking at the API documentation, but there are very few examples, and none on how to use it to refer to another question.
Thanks,
Tricia
Best answer by TomG
@TriciaB,
@bstrahin is close, but I'm guessing that "2" is the recode, not the label. So, I think what you really want is:
```
if(parseInt("${q://QID1/SelectedChoicesRecode}") == 2) this.setChoiceValue(2, true);
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.