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

Auto-select multiple choice answer for participants

  • Feb 21, 2021 9:33 PM UTC
  • 2 replies
  • 130 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();
});

View original

2 replies

Forum|alt.badge.img+8
  • Level 2 ●●
  • Answer
  • Feb 22, 2021 5:26 AM UTC

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
  • Feb 22, 2021 5:50 AM UTC