Solved
set embedded data from this.questionId SelectedChoicesRecode
Hi Qualtrics Community!
I am trying to use javascript to write a value to embedded data based on the current questions Recoded Values. I know how to do this if the QuestionID is known, but I don't know how to string the code toegether to refer to this.questionId (I'd like to use the same javascript for a large number of questions without modifying it to refer to the specific question IDs).
The functionality I am looking for is essentially "If this.questionId's SelectedChoicesRecode = 1 then set embedded data "c" = 1, else "c" = 0.
Any pointers are appreciated!
G2000
Best answer by TomG
> @G2000 said:
> Thanks @fleb!
> This definitely worked. Only downside is that this grabs the response number, not Recoded Value (and I am not knowledgeable enough to adjust that). But I can make that work in this case!
> Thanks again!
> G2000
This will give you what you want:
```
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices());
var c = (selectedRecode == "1") ? 1 : 0;
Qualtrics.SurveyEngine.setEmbeddedData("c", c);
});
```
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
