How to pre populate the options in the second column of a Side By Side Question | XM Community
Question

How to pre populate the options in the second column of a Side By Side Question

  • 31 January 2021
  • 8 replies
  • 174 views

Userlevel 3
Badge +5

In my survey I have a Side By Side question. Within this question I would like to have the Multiple Choice options be pre populated by an earlier question. I want to do this by using Javascript. I tried three options without result:
this.setChoiceAnswerValue(2,2,true);
this.setChoiceValue(2,2,true);
this.setChoiceValueByRecodeValue(2,2,true);
The question looks like the screenshot below:
SBS Question.pngCan somebody help me giving me the right JavaScript code?
Thanks in advance.


8 replies

Userlevel 7
Badge +21

Due to the way in which the SBS questions are structured internally, I highly doubt this will be possible. Instead of being one question, the SBS questions are split into SBS1, SB2 etc. You can however click on the options to prepopulate them.
Each answer in a matrix style SBS question has it's id in the following format:

QR~QuestionId#ColumnNumber~Row~MatrixColumnNumber

So assuming your question id QID13, in your case, Answer 2 of Statement 1 in Column 2 will have the id:
QR~QID13#2~1~2

To prepopulate it, you can use
document.getElementbyId("QR~QID13#2~1~2").click()

Badge +5

What about if it is just a single answer question? We want people to opt-OUT of a question so I want it prepopulated.

So I took it to be this b/c there is no columns, but it isn’t working:

document.getElementbyId("QR~QID448#1").click()

 

Here is the opt-out language with a box hopefully prepopulated:

* Click here to opt-out of receiving updates, offers, and content.

Badge +5

Does it depend on theme and layout for this to work?

Userlevel 7
Badge +27

Does it depend on theme and layout for this to work?

It won’t work with Simple Layout.

Badge +5

Thanks Tom. I’m a novice coder. Does that code look right to you? It isn’t working (I’m not in Simple Layout) and wondering if I’m missing something. Maybe remove the #1 since it is just a single question? Appreciate it if you know and will share. Basically want the box to pre populate.

 

 

Userlevel 7
Badge +27

The code is for a side-by-side question and your question is a multiple choice.  If you want to check the checkbox by default, go to Default choices, check the box, and Save.

 

 

 

Badge +5

OMG, that was easy. I can’t believe Support didn’t provide me that knowledge when I reached out. Thank you so much!

Userlevel 7
Badge +27

OMG, that was easy. I can’t believe Support didn’t provide me that knowledge when I reached out. Thank you so much!

The image helped a lot. 😀

Leave a Reply