curiouswebster
asked on
Need to use a Timer in JavaScript
I need my JavaScript to create a timer, then I need to code an event that fires when that timer is completed.
How do I code both the creation of the timer and the event?
Thanks.
How do I code both the creation of the timer and the event?
Thanks.
ASKER
Cool. How do I call it?
And can I add data to that event which I can later parse out in the case where I have two or more events firing?
And can I add data to that event which I can later parse out in the case where I have two or more events firing?
ASKER
The data would contain on thing, the ID of the field that was updated.
ASKER
one thing, I meant
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, I do not need to attach data, if it's not possible. When I call setTimeout() the handle returned will be unique. True?
That function will continue to fire until I clear it. BUT, how do I know which instance is firing?
I will have many instances firing and need to be able to find which one it was that initiated it.
That function will continue to fire until I clear it. BUT, how do I know which instance is firing?
I will have many instances firing and need to be able to find which one it was that initiated it.
ASKER
Perfect! Thanks!
ASKER
One last question, how do I stop this from executing? I see that I can use a variable, thusly:
var t=setTimeout("javascript statement",milliseconds);
then t.clearTimeout().
But must I keep a list of my own, where I asociate an id with that handle returned by setTimeout()?
var t=setTimeout("javascript statement",milliseconds);
then t.clearTimeout().
But must I keep a list of my own, where I asociate an id with that handle returned by setTimeout()?
// set your event here
// set your event here
// set your event here
// set your event here
// set your event here
// set your event here
// set your event here
// set your event here
}, 2000); // 2 seconds