Autoadvance clearTimeout not working | XM Community
Skip to main content

I tried to use this code to set up a question that autoadvances either after 8 seconds or when a response is chosen. Unfortunately, the clearTimeout isn’t working. If a response is chosen, the following page will autoadvance when 8 seconds has elapsed.

Any help solving this problem would be much appreciated!!

 

Qualtrics.SurveyEngine.addOnload(function() {
this.hideNextButton();
var that = this;
var to = setTimeout(function(){
that.clickNextButton();
},8000);
that.questionclick = function(event,element){
if (element.type == 'radio') that.clickNextButton();
};
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
clearTimeout(to);
});
});

@ks13 Change addOnPageSubmit to addOnUnload and your code will work fine.


That worked! Thanks much.


@ks13 Next time when you customize through JS, just follow the structure that Qualtrics already put out for us

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*/

});

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

});

 


Leave a Reply