Auto-selecting answers from a multiple choice question | XM Community
Solved

Auto-selecting answers from a multiple choice question

  • 28 March 2022
  • 1 reply
  • 313 views

Badge +1

Hello all,
I have a scenario where I have a question with a list of answers that need to be in different order based on language. So I thought of creating a version in French and a version in English of this question, then merging the two into a hidden question. Here is my JS code so far:
2022-03-28_16-59-44.pngI believe my issue is the respondent can select more than one answer. I believe the codes are then stored in an array where I need to use the split function and then a loop, but I can't seem to figure it out. Any help would be appreciated!
P.S. I am aware I can achieve my desired results within the reporting or using an embedded data element, but I wanted to use this method.

icon

Best answer by NiC 29 March 2022, 08:52

View original

1 reply

Userlevel 7
Badge +27

Hi Ajoly ,

you can add the following code after the if else block
var codexArray = codex.split(',')
var that =this


for (let option in codexArray){
    that.setChoiceValueByRecodeValue(codexArray[option], true)
}

Leave a Reply