codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  setTimeout for custom objects  dbdwe3m at 19:45 on Wednesday, August 11, 2004
 

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;







CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  grouping records
•  loop through form checkboxes
•  Java Help
•  Pre-load Rotating Photographs
•  need help to customize a dhtml script.
•  Implementing setTimeout causing problems
•  setTimeout for custom objects
•  How to change dynamically the value of CONTENTof META object ?
•  How to change the value of CONTENTof META object ?


Recent Articles
Simple Thumbnail Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)
Function to Return Alpha Characters Only
The OSI Reference Model - A Clear and Concise Illustration !


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004