And a little on the side.
Keeping in mind Airblader's warning about timer accuracy, at least you can simplify the code.
There is no reason for separate variables for seconds and tenths-of-seconds.
Oh, and your use of
document.counter.d2.value would indicate you are using a
named <form>, which is considered obsolete. So assuming you have a <form> with, properly, an id such as
<form id="counter">:
Code:
var ticker = 0;
var countField = document.getElementById("counter").d2;
function tick( )
{
if ( (ticker-=0.1) <= 0 ) { ticker = 60; }
countField.value = ticker.toFixed(1);
}
tick( );
setInterval( tick, 100 );
That counts DOWN from 60 to 0.1 before resetting to 60.
If you wanted to go UP, from 0 to 59.9 before resetting to 0:
Code:
var ticker = 60;
var countField = document.getElementById("counter").d2;
function tick( )
{
if ( (ticker+=0.1) >= 60 ) { ticker = 0; }
countField.value = ticker.toFixed(1);
}
tick( );
setInterval( tick, 100 );