Populate choices in a Rank Order question by Javascript

gennariagennaria St. LouisCommunity Member Qubie ✭

Populate choices in a Rank Order question by Javascript

Short version: I'm new to Javascript and I'm trying to create the choices in a Rank Order question from an array in an embedded field. I'm unclear if this is possible and which API option to use. I'm currently trying this:

Qualtrics.SurveyEngine.addOnload(function()

{

var rankChoices = "${e://Field/embeddedFieldName}";

rankChoices.forEach(function(itemText, i) {

this.setChoiceAnswerValue(i, itemText);

});

});


Longer version: I've created a loop and merge. The loop has a couple of questions in it and at the end of each loop I append the final answer to an embedded data field. The embedded data field ends up looking like this (item1,item2,item3,item4). After the respondent completes the loop I want to have them rank the items in the array. I realize that I could create a bunch of embedded data fields, but it would require up to 50 fields and the number will vary. I intend to reuse the survey with different clients and just change the data in the loop fields each time. I'm hoping for a more elegant solution.

Sign In to Comment