Auto-select multiple choice answer for participants | XM Community
Skip to main content
Solved

Auto-select multiple choice answer for participants

  • February 21, 2021
  • 2 replies
  • 96 views

I would like to randomly choose a multiple choice answer for participants (like randomization). I will not be displaying this question to participants.  
My goal is to randomize without creating a dozen extra questions and excessive display logic. Hence, not wanting to use randomization and do extra survey flow work. This would allow me to be able to pipe the (randomly chosen) answer into the next questions.

Best answer by ChiragK

Hi LBG
Try adding this Java Script code in that question, hope this helps.
Qualtrics.SurveyEngine.addOnReady(function () {
    var $this = jQuery(this.questionContainer);
    $this.hide(); //this line will hide the question for participants
    var $choices = jQuery(".QuestionBody .ChoiceStructure .LabelWrapper label[for]", $this);
    var randomChoice = Math.floor(Math.random() * $choices.length + 1) - 1;
    jQuery(".QuestionBody .ChoiceStructure .LabelWrapper label[for]:eq(" + randomChoice + ")", $this).click();
});

2 replies

Forum|alt.badge.img+8
  • Level 2 ●●
  • Answer
  • February 22, 2021

Hi LBG
Try adding this Java Script code in that question, hope this helps.
Qualtrics.SurveyEngine.addOnReady(function () {
    var $this = jQuery(this.questionContainer);
    $this.hide(); //this line will hide the question for participants
    var $choices = jQuery(".QuestionBody .ChoiceStructure .LabelWrapper label[for]", $this);
    var randomChoice = Math.floor(Math.random() * $choices.length + 1) - 1;
    jQuery(".QuestionBody .ChoiceStructure .LabelWrapper label[for]:eq(" + randomChoice + ")", $this).click();
});


  • Author
  • February 22, 2021