Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Firefox JavaScript Console Error: Form1 is not defined

Reply
Thread Tools

Firefox JavaScript Console Error: Form1 is not defined

 
 
Jon Natwick
Guest
Posts: n/a
 
      03-01-2005
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


 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      03-01-2005
Instead of 'Form1', try something like document.getElementById('Form1').
Maybe store it in a local variable if you need it multiple times.

"Jon Natwick" <> wrote in message
news:zO1Vd.24193$...
> 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
>
>



 
Reply With Quote
 
 
 
 
Wilco Bauwer
Guest
Posts: n/a
 
      03-01-2005
Or document.all["Form1"], or document.forms[0] (afaik).

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      03-01-2005
to access the form you can use

any browser:

document.Form1
document.forms['Form1']
document.forms[0] // if first or only form

modern browsers

document.getElementsByName('Form1')[0]
document.getElementById('Form1') // requires id tag

ie only:

Form1
document.all('Form1')


-- bruce (sqlwork.com)




"Jon Natwick" <> wrote in message
news:zO1Vd.24193$...
| 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
|
|


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
form1.submit(); in Firefox? Works in IE jodleren Javascript 3 03-27-2007 12:46 PM
How to write to Firefox's JavaScript console? kj Javascript 2 01-03-2007 12:42 PM
Javascript form validation script- not defined in Mozilla Firefox nektir@gmail.com Javascript 8 10-05-2006 07:56 PM
FireFox Javascript Console Tutorial Roger Javascript 2 04-03-2005 05:51 PM
Firefox JavaScript Console Error: Form1 is not defined Jon Natwick ASP .Net 0 03-01-2005 07:53 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57