JavaScript Global Counter Variable | XM Community
Skip to main content

JavaScript Global Counter Variable

  • February 25, 2023
  • 2 replies
  • 209 views

Forum|alt.badge.img

Hi,
I am a few attention-check questions in my questionnaire, and the rule is that respondents can only fail one of them; the second failure will end the survey. Using Javascript, a warning will be generated that the respondents failed an attention check question, and if they fail again, the survey will end. However, for this to work properly, I need a global counter variable, so I can keep track of the respondent's previous failure through the survey and have the platform act accordingly upon the second failure. I can not find a way to set up a global counter variable independent of each question code. I would appreciate any hint, help, or guidance on how to solve this issue.

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 26, 2023

You can't have a global JavaScript variable. You'll need to use an embedded data field.


Forum|alt.badge.img
  • Author
  • February 26, 2023

Thank you for helping me out. It worked