I'm trying to dynamically set an Embedded Data field called nparent using JavaScript within a Qualtrics question block, but it's not working.
Here’s what I’ve done:
I have a question called nparent with two options:
Ja (recode value: 2)
Nei (recode value: 1)
I want to set nparent as false if the user selects "Nei" and true otherwise, so I can use it for logic in subsequent questions in the same block. Here’s the JavaScript I’ve tried:
js Copy Edit
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var selected = "${q://QID1215410936/SelectedChoicesRecode}";
if (selected === "1") {
Qualtrics.SurveyEngine.setEmbeddedData("nparent", "false");
} else {
Qualtrics.SurveyEngine.setEmbeddedData("nparent", "true");
}
});
Any insights into what I might be missing?
Appreciate any help!