Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Date | Q1203 [ previous next ]

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?

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.