J
Jon Natwick
This "Countdown Timer" code works fine with Ie, but I receive an "Error:
Form1 is not defined" error with Firefox 1.0.0 and 1.0.1.
<body MS_POSITIONING="FlowLayout" onload="InitializeTimer()">
<form name="Form1" method="post" action="test.aspx" id="Form1">
<script language=JavaScript> var mins, secs, timerID = null, timerRunning =
false, delay = 1000; function InitializeTimer() { mins =
Form1.tbMins.value;
secs = Form1.tbSecs.value; StopTheClock(); StartTheTimer(); } function
StopTheClock() { if(timerRunning) clearTimeout(timerID); timerRunning =
false; } function display(min, sec) { var disp; if(min<=9) disp=' 0';
else
disp=' '; disp += min + ':'; if(sec<=9) disp += '0' + sec; else disp +=
sec;
return(disp); } function decrement() { secs--; if(secs == -1) { secs =
59;
mins--; } } function StartTheTimer() { if (mins == 0 && secs == 0) {
document.Form1.hTimer.value = display(mins, secs); self.status =
display(mins, secs); StopTheClock(); } else {
document.Form1.hTimer.value =
display(mins, secs); self.status = display(mins, secs); decrement();
timerRunning = true; timerID = self.setTimeout('StartTheTimer()',
delay); } } } </script>
Any ideas??
If I take out the Form1 prefix, it doesn't work in either Ie or Firefox.
Thanks in advance,
Jon
Form1 is not defined" error with Firefox 1.0.0 and 1.0.1.
<body MS_POSITIONING="FlowLayout" onload="InitializeTimer()">
<form name="Form1" method="post" action="test.aspx" id="Form1">
<script language=JavaScript> var mins, secs, timerID = null, timerRunning =
false, delay = 1000; function InitializeTimer() { mins =
Form1.tbMins.value;
secs = Form1.tbSecs.value; StopTheClock(); StartTheTimer(); } function
StopTheClock() { if(timerRunning) clearTimeout(timerID); timerRunning =
false; } function display(min, sec) { var disp; if(min<=9) disp=' 0';
else
disp=' '; disp += min + ':'; if(sec<=9) disp += '0' + sec; else disp +=
sec;
return(disp); } function decrement() { secs--; if(secs == -1) { secs =
59;
mins--; } } function StartTheTimer() { if (mins == 0 && secs == 0) {
document.Form1.hTimer.value = display(mins, secs); self.status =
display(mins, secs); StopTheClock(); } else {
document.Form1.hTimer.value =
display(mins, secs); self.status = display(mins, secs); decrement();
timerRunning = true; timerID = self.setTimeout('StartTheTimer()',
delay); } } } </script>
Any ideas??
If I take out the Form1 prefix, it doesn't work in either Ie or Firefox.
Thanks in advance,
Jon