|
I have a timer script I modified to be object oriented since I need multiple unique timers on one page that work independently. Everything seems to work fine except this function where it calls the timeout.
function showtime(form)
{
this.seconds = this.seconds + 1;
if (this.seconds == 60)
{
this.seconds = 0;
this.minutes = this.minutes+1;
}
if (this.minutes == 60)
{
this.minutes = 0;
this.hours = this.hours + 1;
}
var timeValuehr = "" + ((this.hours < 10) ? "0" : "") + this.hours;
var timeValuemin = "" + ((this.minutes < 10) ? "0" : "") + this.minutes;
var timeValuesec = "" + ((this.seconds < 10) ? "0" : "") + this.seconds;
document.forms[form].time.value = timeValuehr + ":" + timeValuemin + ":" + timeValuesec;
this.timerID = setTimeout(this.name+".showtime('"+form+"');",1000);
this.timerRunning = true;
}
this.name is part of my custom objects values I assigned in the object creator function and showtime is a prototype function for that object. This funciton is what updates the display to show the timer running. I get an error saying 'Object does not support this function'
Here is the object generator code
function Clock(seconds,minutes,hours,timerID,timerRunning,startClicked,name)
{
this.seconds = seconds;
this.minutes = minutes;
this.hours = hours;
this.timerID = timerID;
this.timerRunning = timerRunning;
this.startClicked = startClicked;
this.name = name;
}
Clock.prototype.showtime=showtime;
|
|
|
|
|
|
|
|