JavaScript & Pick, Group and Rank | XM Community
Skip to main content

Hi there - new to here! I've got a Pick, Group and Rank question where users will drag and drop items (images of a CAD $1) to one of 2 groups (see screenshot below).
Screen Shot 2020-05-05 at 11.13.39 PM.png
I added the following JS:
Screen Shot 2020-05-05 at 11.16.47 PM.pngThese variables are also in my survey flow:
Screen Shot 2020-05-05 at 11.17.14 PM.pngThe on the next page, I want the embedded piped text to sum the number of items in each of the groups so that the value of the number of items in each group from the question before shows up.
Screen Shot 2020-05-05 at 11.17.40 PM.pngHowever, this isn't working for me. Any advice?

The code is correct, it is just written at wrong place. Still using the above code the ED will be set but we can use it only on the next to next page from the page were we have written the JS.
In order to use it on the very next page use the below code:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
var that = this;
if(type == "next")
{
Qualtrics.SurveyEngine.setEmbeddedData("AlexCount", jQuery("#"+that.questionId+"group0 li").length);
Qualtrics.SurveyEngine.setEmbeddedData("JeffCount", jQuery("#"+that.questionId+"group1 li").length);
}
});


Thank you SO much! It worked!! Such a relief. I really appreciate your help.


Leave a Reply