Retrieving selected choice in slider questions using JS | XM Community
Skip to main content

I’m having trouble extracting the selected choices in slide questions. 

For multiple choice questions, I was able to use this.getSelectedChoices in addOnPageSubmit. However, using the same thing for slider questions gives me the value of 4 regardless of what values I choose in preview. I tried getChoiceValue too, but it return null regardless of what I choose. 

My goal is to compare the selected answer with my correct answer, which determines what happens next in the survey for this participant. 

Has anyone dealt with this before? 

@CindyJ You may check this comment.


@CindyJ - Use this.getChoiceAnswerValue(1) where 1 is the choiceid of the first slider.


@CindyJ - Use this.getChoiceAnswerValue(1) where 1 is the choiceid of the first slider.

Right now, I have 

But it still gives me null:

Does anyone have any idea why this is? Did I fail to submit the selected answer?


@CindyJ,

This works for me:

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
console.log(this.getChoiceAnswerValue(1));
});

Perhaps the choiceid of the slider isn’t 1.


@CindyJ,

This works for me:

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
console.log(this.getChoiceAnswerValue(1));
});

Perhaps the choiceid of the slider isn’t 1.

I opened a different survey and started over and your code is working now! There as probably something wrong with my settings for the slider earlier. 

Thank you so much!!


Leave a Reply