hi, i first write a settimeout function so that if people don't react in 30 seconds, the next button will be automatically clicked.
var timeout;
timeout = setTimeout(function(){
jQuery("#NextButton").click();
},
30000);
but if people click some button on the screen, i want to show them message, proceed them to next block:
if they click the quit button, the next button will be automatically clicked: And i use clearTimeout function to stop the previous settimeout function running, otherwise the next block's next button will be clicked after 30 seconds
jQuery('#QuitQButton').on('click', () => {
jQuery("#QuitMsg").show();
jQuery("#NextButton").click();
clearTimeout(timeout);
});
but the clearTimeout function doesn't work? if i click the quit button, i automatically proceed to next block, but after some time, the next button in the new block is automatically clicked by the settimeout function defined in the previous block
what is the right way to write these two functions? (i) i tried cleartimeout but it does not work (ii) i want to use variable quit = 0, if the quitbutton is clicked, i can set quit = 1. the settimeout function only runs for quit = 0. How can i define a variable in both functions? (iii) or how can I prevent the previous block's javascript running if i proceed to the next block
many thanks!!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.