Auto select from multiple select question | XM Community
Skip to main content
Question

Auto select from multiple select question

  • September 13, 2023
  • 1 reply
  • 86 views

Forum|alt.badge.img+3

 

Could someone help me with my JavaScript code?

In question QID4, I have a gender selection question. If someone chooses 'Prefer not to say,' I'd like to automatically select '1. Terminate on the next page.

 

I wrote JavaScript code, but no matter which option I choose in QID4, it always auto selects option 2, 'Continue.

Qualtrics.SurveyEngine.addOnload(function() {
    var gender = "${q://QID4/ChoiceGroup/SelectedChoices}";

    if (gender === "4") {
        this.setChoiceValueByRecodeValue(1, true);
    } else {
        this.setChoiceValueByRecodeValue(2, true);
    }
});

1 reply

Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1096 replies
  • September 13, 2023

@hachiware10  just change (gender === "4") to (gender == "Prefer not to say") also put a pagebrake between 2 question