Hello,
I have a problem with settimeout.
When I call the initCountDown method on body's onLoad event. If I call the initCountDown on body's load, the button's code works fine afterwards.
However, if I do not place initcountDown in body's load, the button calls countDown method only once and settimeout does not function.
Any help or tips would be greatly appreciated.
Thanks
*************** *************** ***************
[CODE=javascript]<SCRIPT language="JavaS cript">
var secs;
var timeout;
function initCountDown(i nit) {
secs = init;
countDown();
}
function countDown () {
if (secs >= 0) {
self.status = secs;
secs = secs - 1 ;
timeout = setTimeout(func tion(){countDow n();}, 1000);
} else {
clearTimeout(ti meout);
}
}
</SCRIPT>
<body onload="initCou ntDown(10)">
<form>
<INPUT type=submit id=btnCount value="Count Down" onClick = "initCountDown( 10)">
</form>
</body>[/CODE]
I have a problem with settimeout.
When I call the initCountDown method on body's onLoad event. If I call the initCountDown on body's load, the button's code works fine afterwards.
However, if I do not place initcountDown in body's load, the button calls countDown method only once and settimeout does not function.
Any help or tips would be greatly appreciated.
Thanks
*************** *************** ***************
[CODE=javascript]<SCRIPT language="JavaS cript">
var secs;
var timeout;
function initCountDown(i nit) {
secs = init;
countDown();
}
function countDown () {
if (secs >= 0) {
self.status = secs;
secs = secs - 1 ;
timeout = setTimeout(func tion(){countDow n();}, 1000);
} else {
clearTimeout(ti meout);
}
}
</SCRIPT>
<body onload="initCou ntDown(10)">
<form>
<INPUT type=submit id=btnCount value="Count Down" onClick = "initCountDown( 10)">
</form>
</body>[/CODE]
Comment