How do you make a countdown in JS? like it counts down 5 4 3 2 1 0 in a form field. it's for a page redirect. so when the page loads it says:
you will be redirected in "number" seconds
i'm stumped so i hope somebody can help!
| SitePoint Sponsor |


How do you make a countdown in JS? like it counts down 5 4 3 2 1 0 in a form field. it's for a page redirect. so when the page loads it says:
you will be redirected in "number" seconds
i'm stumped so i hope somebody can help!
[ metabahn ] : changing the course of the web.
Try search hotscripts.com. Something like was definetely made by someone already.





Something like this?
function countdown(s)
{
mySpan.innerText = s + ' seconds left...';
//mySpan = <span id="mySpan"></span> somewhere in the document
s--;
setTimeout('countdown('+s+')', 1000);
if(s <= 0) //do whatever you want to do...
}
Bookmarks