Hello,
I have a situation where respondents can select multiple responses to Q1 (a list that could have up to 100 possible options). I then want to narrow the selected list down to 5 random options and assign these 5 responses to some embedded variables, for later use.
So that I can make sure these random 5 options are evenly distributed amongst the total sample, I’m utalising the 'Advanced Ramodization' feature to select my 5, but I’m not sure how to then extract the 5 selected options into the relevant embedded variables.
My current thinking was to use the following script, but it isn’t working…
Qualtrics.SurveyEngine.addOnload(function() {
// Retrieve selected options from the advanced randomization
var selectedOptions = this.getSelectedChoices();
// Store the selected options in embedded data elements
for (var i = 0; i < selectedOptions.length; i++) {
var embeddedDataName = 'SelectedOption_' + (i + 1); // Name for embedded data element (e.g., SelectedOption_1, SelectedOption_2, etc.)
Qualtrics.SurveyEngine.setEmbeddedData(embeddedDataName, selectedOptions[i]);
}
});
Can anyone advise where I might be going wrong and how I could get this to work?
Thanks.
Best answer by cgillon
View original