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]