Populate choices in a Rank Order question by Javascript | XM Community
Question

Populate choices in a Rank Order question by Javascript

  • 3 April 2020
  • 0 replies
  • 89 views

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.


0 replies

Be the first to reply!

Leave a Reply