I have two multiple choice questions asking about respondents' own perceived ranking in groups, let's call them group1 and group2. Both questions allow for responses from 1 to 10. I'd like to use the responses from these to questions to see if they're better, worse, or the same based on their responses to these two questions. As an example, if a respondent chooses a ranking of 7 in group1 and 4 for group2, a third question will point out that their perceived ranking is lower in group2 than it is in group1. Here's my setup so far:
Embedded data at top of survey flow:
The third question, where I'd like to show the respondent their difference in ranking, better, worse, or same:
And my javascript associated with the third question:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
var group1 = parseInt("${q://QID21/ChoiceGroup/SelectedChoices}");
var group2 = parseInt("${q://QID22/ChoiceGroup/SelectedChoices}");
var result;
if (group1 > group2) { result = "better";} else if (group1 < group2) { result = "worse";} else { result = "same";}
Qualtrics.SurveyEngine.setEmbeddedData("result",result);
});
The result is that I only get 'null' where I'm expecting better / worse / same to show up.
New to javascript so any pointers would be greatly appreciated. Thanks!
Best answer by bgooldfed
View original