JavaScript Global Counter Variable | XM Community
Skip to main content

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.

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


Thank you for helping me out. It worked


Leave a Reply