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

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

  • January 31, 2021
  • 8 replies
  • 316 views

Nico_Leussink
Level 2 ●●
Forum|alt.badge.img+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

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • January 31, 2021

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()


Forum|alt.badge.img+5
  • Level 1 ●
  • 11 replies
  • September 14, 2023

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.


Forum|alt.badge.img+5
  • Level 1 ●
  • 11 replies
  • September 19, 2023

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 19, 2023
djunius wrote:

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

It won’t work with Simple Layout.


Forum|alt.badge.img+5
  • Level 1 ●
  • 11 replies
  • September 19, 2023

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.

 

 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 19, 2023

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.

 

 

 


Forum|alt.badge.img+5
  • Level 1 ●
  • 11 replies
  • September 19, 2023

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • September 19, 2023
djunius wrote:

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