I have a question with 5 choices (A,B,C,D,E), displayed in random order. Say for a particular user they are displayed in the order C, D, A, E, B
I want to set embedded data field "Output" based on the displayed order of the selected choice. In the above example: if the user chose C, I want Output = 1; if the user chose E, output = 4 and so on.
(Similarly, if the displayed order was A,D,C,B,E - if the user chose C, output = 3 etc). User can select only one choice.
What is a good way to implement this?
I tried the following, but it sets Output to the order of choices listed in the question, not the displayed order.
this.questionclick = function(event,element)
{
console.log(event,element);
if (element.type == 'radio')
{
var choiceNum = element.id.split('~')[2];
Qualtrics.SurveyEngine.setEmbeddedData("Output", choiceNum);
}
Thanks!
All that matters is which choice is selected when you click Next. So, you can do this:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
jQuery("#"+this.questionId+" [type=radio]").each(function(i) {
if(this.checked) {
Qualtrics.SurveyEngine.setEmbeddedData("Output",i+1);
return false;
}
});
});