|
|
Help me with a countdown script
|
|
|
|
Mac Elite
Join Date: Apr 2002
Location: Quetzlzacatenango
Status:
Offline
|
|
Hey boys and girls,
I want to put a timer on a page I coded that will count down to the day of the US Federal Elections (November 2, 2004). I think it would be cool to have it precise down to the millisecond, much like the Flash counter that Apple had on its page counting down to the release of the PowerMac G5.
Does anyone know a good script/applet that can do this? If it needs to be done in Flash (for aesthetic purposes) then I might be up a creak, but it's worth a shot.
Thanks,
Oz
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Oct 2003
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Apr 2002
Location: Quetzlzacatenango
Status:
Offline
|
|
Thanks for the reply. This is a cool script, but I'm wondering if it's possible to edit it so that it counts down to the millisecond. Do you know what I could add to the script to make it do so?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by Ozmodiar:
Thanks for the reply. This is a cool script, but I'm wondering if it's possible to edit it so that it counts down to the millisecond. Do you know what I could add to the script to make it do so?
The browser CPU load required to display that kind of update would be bad. I did a simple test counting down from 1000 to 0 over and over (setInterval of 1 ms) and it pegs the CPU in my 900Mhz G3 and still takes longer than 1ms per update.
Here's some code you can play with:
[php]
<html>
<head>
<script language="JavaScript">
function showMilliseconds()
{
newmillivalue = document.forms[0].milliseconds.value -1;
if ( newmillivalue < 0 )
{
newmillivalue = 999;
document.forms[0].itercount.value = parseInt(document.forms[0].itercount.value) +1;
}
document.forms[0].milliseconds.value = newmillivalue;
}
</script>
</head>
<body onload="setInterval('showMilliseconds()', 1)">
<form>
Count: <input type="text" name="itercount" value="0">
<br/>
Milliseconds: <input type="text" name="milliseconds" value="0">
<br/>
</form>
</html>
[/php]
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Oct 2003
Status:
Offline
|
|
I dunno if I would want to count to the millisecond in javascript. Would probably want to use flash or something of the sort for that.
Here is a tutorial on how to do it with flash, including milliseconds:
http://www.kirupa.com/developer/mx/countdown.htm
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Apr 2002
Location: Quetzlzacatenango
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|