Get recode value of two questions | XM Community
Skip to main content

Hi,
since I'm quite new to JS (and especially to JS in Qualtrics), I'm struggling with the following task:
When the page unloads, I want to do some custom calculation and save the result in an embedded data field. Since the calculation is rather complex, I can't use the math operations in survey flow.
I guess I know how to do the calculation and how to store the embedded data, but how can I best retrieve the recode values of an answered question (Question IDs are known: QID7 // QID8)?
Some additional information: QID7 and QID8 are both Multiple Choice (single answer!) questions displayed on the same page.
Thanks!
Manfred

Hi Manfred,
I can only get it to work with a pagebreak between the two questions so hopefully someone can improve on this answer. But this is the code I have so far which works if the questions are on 2 pages:
Qualtrics.SurveyEngine.addOnPageSubmit(function() 
{
var Answer1 = "${q://QID7/SelectedChoicesRecode}";
var Answer2 = this.getChoiceAnswerValue();
var FinalAnswer = parseInt(Answer1) + parseInt(Answer2);
Qualtrics.SurveyEngine.setEmbeddedData( 'FinalAnswer ', FinalAnswer );
});

I hope this helps a bit :)
Steph


Thanks, StephH72!
As a last resort I'll have to insert a page break.
Or I just run the calculation on the first question of the next page. Certainly not the best coding style, though.


Leave a Reply