i have a stopwatch which works:
my showtime function is working by using setTimeOut. i have been told that itis not that accurate and does not take into account the execution time for the code. What i actually want to do is save the start time and then take the difference between the two when i update the stopwatch.
my existing function is shown below. can anyone show me how to change this function to use the timing method i have described above?
showtime = function(){
seconds = seconds + 1
if (seconds == 60)
{
seconds = 0;
minutes = minutes + 1;
}
if (minutes == 60)
{
minutes = 0
hours = hours + 1
}
var timeValuehr = “” + ((hours < 10) ? “0” : “”) + hours;
var timeValuemin = “” + ((minutes < 10) ? “0” : “”) + minutes;
var timeValuesec = “” + ((seconds < 10) ? “0” : “”) + seconds;
document.formTimeRec.elements[‘tbClock’].value = timeValuehr + ” : ” + timeValuemin + ” : ” + timeValuesec;
timerID = setTimeout(“showtime()”, 1000);
timerRunning = true;
}