Can you access the position of an element in the randomizer | XM Community
Skip to main content
Solved

Can you access the position of an element in the randomizer

  • March 5, 2020
  • 2 replies
  • 6 views

Rudi
QPN Level 3 ●●●
Forum|alt.badge.img+16
  • QPN Level 3 ●●●
Dear all, we have the challenge that we need to present 3 questions in a randomized order. The question texts are dependent on the position of the question. The idea is to have the question text variable and set it according to the position. Therefore it would be helpful to know if we can get the position information during the run time Thanks for your help Best regards Rudi

Best answer by TomG

You could do something like: ``` var qids = []; jQuery(".QuestionOuter").each(function() { qids.push(this.id) }); ``` The qids array will contain the question ids in their randomized order, and you can use it to modify your questions as needed.

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • March 5, 2020
You could do something like: ``` var qids = []; jQuery(".QuestionOuter").each(function() { qids.push(this.id) }); ``` The qids array will contain the question ids in their randomized order, and you can use it to modify your questions as needed.

Rudi
QPN Level 3 ●●●
Forum|alt.badge.img+16
  • Author
  • QPN Level 3 ●●●
  • March 11, 2020
Thank you Tom, very helpful