I have a strange issue with a counter I use to find out how long is spent on a form. On the majority of computers I have checked this works fine, on other computers it counts two times faster than normal and will only update the seconds portion instead of cascading to minutes. All computers run the same os and have similar specs, the script still does it when cache is cleared. Any suggestions would be helpful.
Code:
var counter = 0;
var _myTimer_ms = null;
var _myTimer_s = null;
var _myTimer_m = null;
var _myTimer_h = null;
function updateMS() { document.tracker.mssec.value = (100+parseInt(document.tracker.mssec.value)) % 1000; }
function updateS() { document.tracker.sec.value = (1+parseInt(document.tracker.sec.value)) % 60; }
function updateM() { document.tracker.tmin.value = (1+parseInt(document.tracker.tmin.value)) % 60; }
function updateH() { document.tracker.hour.value = (1+parseInt(document.tracker.hour.value)); }
function startIt() {
stopTimers();
resetTime();
_myTimer_ms = setInterval("updateMS()",100);
_myTimer_s = setInterval("updateS()",1000);
_myTimer_m = setInterval("updateM()",1000*60);
_myTimer_h = setInterval("updateH()",1000*60*60);
}
function startItAgain() {
_myTimer_ms = setInterval("updateMS()",100);
_myTimer_s = setInterval("updateS()",1000);
_myTimer_m = setInterval("updateM()",1000*60);
_myTimer_h = setInterval("updateH()",1000*60*60);
}
function stopTimers() {
clearInterval(_myTimer_ms);
clearInterval(_myTimer_s);
clearInterval(_myTimer_m);
clearInterval(_myTimer_h);
}
function resetTime() {
document.tracker.mssec.value=0;
document.tracker.sec.value=0;
document.tracker.tmin.value=0;
document.tracker.hour.value=0;
}
startIt() is called onload
html:
<input onclick="startItAgain();" type="button" value="Start" style="font-size: 10px;">
<input onclick="stopTimers();" type="button" value="Stop" style="font-size: 10px;">
<BR>
Hours: <input style="font-size: 10px; text-align: right;" id="counter" SIZE="4" onfocus="blur();" name="hour">
Minutes: <input style="font-size: 10px; text-align: right;" id="counter" size="4" onfocus="blur();" name="tmin">
Seconds: <input style="font-size: 10px; text-align: right;" id="counter" SIZE="4" onfocus="blur();" name="sec">
<input id="counter" style="visibility: hidden" onfocus="blur();" name="mssec">