Thank you for the unnecessary candor. Here is the code:
function startTimer() {
running = true;
var now = new Date();
start =now.getTime();
var seconds = getSec();
var setTime = 1000 * seconds;
endTime = start + setTime;
showCountDown()
}
function getSec() {
var r = document.frm.radio1;
for (var i=0; i<r.length; i++) {
if (!r[i].checked) continue;
else return r[i].value;
}
return null;
}
function showCountDown() {
var present = new Date();
moment = present.getTime();
if (endTime - moment<= 0) {
stopTimer();
displayTimer.innerHTML = "TIME'S UP!";
showTimeOver();
} else {
var lapse = new Date(moment - start);
var minLapse = lapse.getMinutes();
var secLapse = lapse.getSeconds() + 1;
var timeLapse = minLapse;
timeLapse += ((secLapse < 10) ? ":0" : ":") + secLapse;
document.frm.timeLapse.value = timeLapse;
var delta = new Date(endTime - moment);
var theMin = delta.getMinutes();
var theSec = delta.getSeconds();
theTime = theMin;
theTime += ((theSec < 10) ? ":0" : ":") + theSec;
document.frm.timerDisplay.value = theTime;
displayTimer.innerHTML = theTime;
if (running) {
timerID = setTimeout("showCountDown()",1000)
}
}
}
function stopTimer() {
displayTimer.innerHTML = theTime + " TIMER STOPPED";
clearTimeout(timerID);
running = false;
}
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Darren Showers wrote on 09 nov 2004 in
microsoft.public.scripting.jscript:
I'm running a timer function that counts down from set time frames.
It has an odd tendency to drop 2 seconds at the beginning but then
work fine the rest of the way. Can anyone suggest what could be
happening here?
What is happening here is that you don't show us the code.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)