Update Variable if Next Button is clicked | XM Community
Skip to main content
Question

Update Variable if Next Button is clicked


Forum|alt.badge.img+2

Hello,

is there a way to add some sort of count on the clicks on the next button? Such that I have an embedded data field that is 0 at the beginning and I want its value to become +1 if the next button is clicked.

Is that possible?

 

Best,

 

Anna

2 replies

qualtrics_nerd
Level 5 ●●●●●
Forum|alt.badge.img+19
  • Level 5 ●●●●●
  • 225 replies
  • April 22, 2023

Hi @anleta ,

Yes it is possible ,  please add below code :
 

Qualtrics.SurveyEngine.addOnload(function()
{
	/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
	/*Place your JavaScript here to run when the page is fully displayed*/
document.getElementById('NextButton').addEventListener("click", setValue);
      function setValue() {

 Qualtrics.SurveyEngine.setEmbeddedData('count', 1);
      }
});

Qualtrics.SurveyEngine.addOnUnload(function()
{
	/*Place your JavaScript here to run when the page is unloaded*/

});

Hope this resolves your query😊!!


Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • April 22, 2023

We can write the JS  in the survey header which increments an embedded data on click of next button.


Leave a Reply