setTimout not stopping

Posted by Ken on Stack Overflow See other posts from Stack Overflow or by Ken
Published on 2010-04-29T10:27:13Z Indexed on 2010/04/29 10:37 UTC
Read the original article Hit count: 353

Filed under:
|

Hi all,

I'm building a quiz and user has 5 seconds to respond to the qeustion if he doesn't resond within the time the answer is 3(wich is a code for no answer). Timer updates just fine until you answer a qeustion from that point the timer runs out of control you see 5,3,4,0 and go to the next qeustion with the answer 3 does anyone know how to kill the old timer?

  function tijd(aantalSec){
    document.getElementById("sec").innerHTML = aantalSec;

    if(aantalSec == 0){
        clearTimeout(tijd);
        antwoord(3);
    }else{
        aantalSec = aantalSec - 1;
        var tijd = setTimeout('tijd(' + aantalSec + ',0)',1000);
    }
    }

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX