irt.org Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt

Q1203 I've seen timers that countdown in weeks, days, hours, minutes and seconds, but how can I show a single figure that counts down once every second?

You are here: irt.org | FAQ | JavaScript | Date | Q1203 [ previous next ]

Try:

<script language="JavaScript"><!--
function tick() {
    if (document.myForm.myCount.value > 0) {
        --document.myForm.myCount.value;
        setTimeout('tick()',1000);
    }
}
//--></script>

<body onLoad="tick()">

<form name="myForm">
<input type="text" name="myCount" value="10">
</form>

©2013 Martin Webb

ArticlesFAQsGamesFeedback

FOLDOCRFCsInstant JavaScriptSoftwareBooksJavaScript Programmer's ReferenceAboutTop