Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time

Status
Not open for further replies.

Maximus007

Technical User
Jul 26, 2004
248
0
0
US
Hi;

I need some help on displaying 30 miuntes counting backwards on a page. I know how to get the time displayed but how to get count back is where I am stuck.

Thank you
 
This shows you count down of 15 sec and show remaining time at the status bar. Generalization is obvious. (Sure you know the status bar is an area which might be rendered forbidden. But this is just a demo.)
[tt]
<script language="javascript">
var dt_remain=15; //seconds; variable global in scope
function dotime() {
window.status="time remaining (sec) : " + dt_remain;
if (dt_remain <= 0) {
dt_remain=15; //reset
window.status="time's up";
} else {
dt_remain--;
setTimeout("dotime()",1000);
}
}
</script>
[/tt]
And counting can be triggered by a button click for instance.
[tt]
<button onclick="dotime()">countdown 15 sec</button>
[/tt]
I'm sure people can come up with fancy design. But this is the essential.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top