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

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

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😊!!


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


Leave a Reply