pull value from side-by-side into javascript | XM Community
Skip to main content
Solved

pull value from side-by-side into javascript

  • September 29, 2021
  • 5 replies
  • 226 views

Hello everyone,
I'm fairly new to qualtrics and javascript and I was hoping you could help me to pull a value from a side-by-side into javascript.
I have a side-by-side with 5 rows. Each rows has a radiobutton in column 2, which requires participants to choose either 'yes' or 'no' (see image below)
Schermafbeelding 2021-09-29 om 12.57.26.pngI want to use javascript to calculate how often the respondent chose 'Yes', how often 'No' and how often they chose nothing at all (the question is not mandatory).
I've tried to refer to the selected answer in row 1, column 2 with piped text like this: ${q://QID71%232/ChoiceGroup/SelectedAnswers/1}, but that doesn't return anything, it seems.
thanks for your help!

Best answer by ChiragK

Hi, You can use below piped text to get for which statements "Ja" was selected. Similarly you can get for which statements "Nee" was selected. And then using simple JS code you can get count of each choices.
${q://QID71%232/ChoiceGroup/SelectedChoicesForAnswer/1} - for 'Ja'
${q://QID71%232/ChoiceGroup/SelectedChoicesForAnswer/2} - for 'Nee'

5 replies

Forum|alt.badge.img+8
  • Level 2 ●●
  • Answer
  • September 29, 2021

Hi, You can use below piped text to get for which statements "Ja" was selected. Similarly you can get for which statements "Nee" was selected. And then using simple JS code you can get count of each choices.
${q://QID71%232/ChoiceGroup/SelectedChoicesForAnswer/1} - for 'Ja'
${q://QID71%232/ChoiceGroup/SelectedChoicesForAnswer/2} - for 'Nee'


MSobotta
Level 4 ●●●●
Forum|alt.badge.img+25
  • Level 4 ●●●●
  • September 29, 2021

You could do so using branch logic in the survey flow. It might be more involved than js, but it would be out of the box. You would just have to have an IF statement and a counter for each item.


  • Author
  • September 30, 2021

  • Author
  • September 30, 2021

https://community.qualtrics.com/XMcommunity/discussion/comment/40854#Comment_40854thanks, I think I see what you mean; if it doesn't work out with the JS I'll give it a try.


Forum|alt.badge.img+8
  • Level 2 ●●
  • September 30, 2021

Hi JVR Please try piping like image below into the next question text so that you know if it shows up and then you can try getting it using JS.
demo.png