Automatically select current question ID when using JS code fro qualtrics counter | XM Community
Skip to main content

I am trying to write code to count the number of times the respond 10 is selected for questions throughout the survey:

```

if("${q://QID1/ChoiceGroup/SelectedChoices}" == 10) {
var counter = "${e://Field/Counter}";
Qualtrics.SurveyEngine.setEmbeddedData("Counter", count + 1);
}

```

However I need to implement this on every question, replacing QID with the given question ID. Because the survey is long, this is cumbersome, so I would like to have one code that can be used in every question and doesn’t require me to manually set the question ID. Is there a way to have this set dynamically based on whatever question the survey respondent is currently on, so that I can simply copy and paste this to each question?

Be the first to reply!

Leave a Reply