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" <(E-Mail Removed)> wrote in message
news:zO1Vd.24193$(E-Mail Removed)-kc.rr.com...
> 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" <(E-Mail Removed)> wrote in message
news:zO1Vd.24193$(E-Mail Removed)-kc.rr.com...
| 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 On
Pingbacks are On
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
Form1.show() errmaker Python 1 02-09-2006 06:14 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM
Page Controls - FindControl - Form1 Mr Newbie ASP .Net 2 09-16-2005 12:58 PM
Firefox JavaScript Console Error: Form1 is not defined Jon Natwick ASP .Net 0 03-01-2005 08:53 PM



Advertisments