Adding (fixed) text to randomly selected choices | XM Community
Skip to main content

I need to display 4 random choices from a list of 15, in random order. But I want to add specific text before the selected choices. For example, if the choices are 1,2,..,15 and choices 9, 4, 2, 7 are selected, I want the following choices displayed:
A9
B4
C2
D7
(Note - the text follows a fixed order - A for the first choice, etc).
Easiest way to do this? Any help would be very appreciated.
Thanks!

You'll need to use JavaScript. First, add a empty span with a class to the beginning of all your choices. For example:
9
Add JS to question:
Qualtrics.SurveEngine.addOnload(function() {
var prefixes = ["A", "B", "C", "D"];
jQuery("#"+this.questionId+" .prefix").each(function(i){ jQuery(this).html(prefixes[i]); });
});


Leave a Reply