View Full Version : Countdown timer - for seconds?
wvccboy
Dec 2nd 2006, 2:22 pm
Hey all,
I need a countdown timer from 10 to 0, which stops once reaching 0.
For some reason I couldn't find any of this on search engines or sites, but it seems pretty simple to me..
Any ideas? Thanks!
Jay
krakjoe
Dec 2nd 2006, 2:26 pm
what do you want the page to do @ 0 ?
wvccboy
Dec 2nd 2006, 2:31 pm
nothing, just stop... it's part of a timing script.. a online game.
Thanks
krakjoe
Dec 2nd 2006, 3:04 pm
ok cool
<div id="counterDiv">
<form name="counter"><input type="text" size="3" name="number"> seconds</form>
</div>
<script>
var countdownfrom=10 // seconds to countdown
var currentsecond=document.counter.number.value=countdownfrom+1
function counter()
{
if (currentsecond!=1)
{
currentsecond-=1
document.counter.number.value=currentsecond
}
else{
// if you really don't want it to do anything then delete the line below
document.getElementById("counterDiv").innerHTML = "Nothin to do"
return
}
setTimeout("counter()",1000)
}
counter()
</script>
techblog
Dec 2nd 2006, 3:08 pm
wow, great script
krakjoe
Dec 2nd 2006, 3:10 pm
It's nice to b nice ... :)
wvccboy
Dec 6th 2006, 6:30 pm
Haven't checked back for a little; but thanks a lot!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.