Hello, I would much appreciate some help. I'm not well-versed in Javascript so I go by examples.
I have a multiple choice question that is populated with data from a webservice. I get and embed the answer options at the start of the survey flow. For Q5 in this case, I used piped text to show the embedded data (e.g. data.0.name, data.1.name, data.2.name, etc.) as answer options.
The data I get from the webservice is dynamic, meaning that
data.0.nameis sometimes choice A and sometimes choice B (or Z, it's a list of 100 ranked items).
To analyse how often each choice is checked, I want to create a variable with the
choiceValuethat is displayed and selected, rather than the original embedded data.
I found and tried adding this snippet as JavaScript to Q5 :
Qualtrics.SurveyEngine.addOnPagcheSubmit(function()
{
if(jQuery("#"+this.questionID+" input[type='checkbox']:checked").attr("choiceId", "1" {
Qualtrics.SurveyEngine.setEmbeddedData("data.0.name", "Test");
});
Alternative 1
Not use the webservice, but I would prefer to find a way to always include this dynamic 'top 100' list, as I suspect it will vary over the course of the year
Alternative 2
Add as embedded data
${q://QID5/ChoiceGroup/SelectedChoices}. However, as far as I know in this case I get one variable with multiple choices, that I'd need to split to get choice counts I can analyze. Any suggestions on how to split the embedded data would be very helpful in this case