View Single Post
Old 04-26-2009, 09:48 AM   #2 (permalink)
CrazeD
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,688

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: Javascript setInterval() method problem

Well since you didn't put the setInterval in your code anywhere, I don't really know where you want it...

However I will say that you should be using setTimeout() instead. setTimeout works exactly the same as setInterval, except it only calls the function once, where as setInterval calls it every X milliseconds.

You said you want to delay the confirmation box from appearing, so I guess this is what you want:

Code:
function guessNumber()                {

    var guessed = document.mathguess.number.value;
    
    if (guessed < rndm)   {
       window.alert("Higher !");
    }
    else if(guessed > rndm)   {
       window.alert("Lower !");
    }
    
       if (guessed == rndm) {
         window.alert("You guessed the number !");
         return setTimeout("confBox()",10000);
       }
       
}

__________________

Need website help? PM me!
CrazeD is online now