Auto-selecting answers from a multiple choice question | XM Community
Skip to main content

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.

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(codexArrayaoption], true)
}


Leave a Reply