Autoadvance clearTimeout not working | XM Community
Skip to main content
Solved

Autoadvance clearTimeout not working

  • October 27, 2024
  • 3 replies
  • 46 views

Forum|alt.badge.img+1

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);
});
});

Best answer by Nam Nguyen

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

3 replies

Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • Answer
  • October 28, 2024

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


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • October 29, 2024

That worked! Thanks much.


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • October 30, 2024

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

});