Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Countdown Timer Question

Reply
Thread Tools

Countdown Timer Question

 
 
Papajo
Guest
Posts: n/a
 
      02-12-2006
This timer counts down from 5 and stops at 0, is there anyway to loop it
so it will start the count down again? plus could the amount of times it
loops be set?
*******Thank you, Joe

http://web2jo.com/Work/Timer.html

 
Reply With Quote
 
 
 
 
Janwillem Borleffs
Guest
Posts: n/a
 
      02-12-2006
Papajo wrote:
> This timer counts down from 5 and stops at 0, is there anyway to loop
> it so it will start the count down again? plus could the amount of
> times it loops be set?
> Thank you, Joe
>


var iCountStart = 5;
var loopCountStart = 3;
var iCount;
var loopCount;
var to;

function startCountdown(start) {
if (start) {
if (to) {
clearTimeout(to);
}
loopCount = loopCountStart;
iCount = iCountStart;
}
if (loopCount > 0) {
window.status = " "+iCount+" ";
if (--iCount < 0) {
loopCount--;
iCount = iCountStart;
}
to = setTimeout('startCountdown(false)', 1000);
}
}


<input type="button" onClick="startCountdown(true)" value="Start">


JW


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a countdown timer for a GUI in blueJ lauraa Software 0 04-18-2010 02:50 PM
Countdown timer for different timezones Dirk Hagemann Python 1 07-06-2006 03:18 PM
Countdown Timer KennethGorelick Python 2 02-19-2006 10:36 PM
JSP countdown timer agold791@hotmail.com Java 4 11-03-2005 02:17 AM
GUI countdown timer in a JApplet? Ryan Stewart Java 2 12-24-2003 07:22 PM



Advertisments