473,461 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error message: document.form1 has no properties

Hello,
I have no javascript knowledge. I am responsible for a website that includes a small amount of javascript, that stops working in firefox. The script begins like this:
Expand|Select|Wrap|Line Numbers
  1. <script = javascript>
  2. }
  3.  
  4. function SameShipping() {
  5.  
  6.  
  7.  
  8. if (document.Form1.Checkbox1.checked)
  9. {    
  10.         document.Form1.shipping_fname.value = document.Form1.fname.value;
  11.         document.Form1.shipping_lname.value = document.Form1.lname.value;
  12.  
  13. <BLAH BLAH>
  14. </script>
The job of the script is to populate the shipping address fields with the billing address data, if the sameshipping checkbox is checked.

The <form> line looks like this:
Expand|Select|Wrap|Line Numbers
  1. <form id="Form1" name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)" action='createaccount.asp?comments=<%=comments & "&shipping=" & shipping%>' method="post">
Here's the sameshipping Checkbox line:
Expand|Select|Wrap|Line Numbers
  1. <INPUT id="Checkbox1" onclick="SameShipping();" type="checkbox" value="ON" name="sameshipping">
The error console tells me: document.form1 has no properties and takes me to this line:
Expand|Select|Wrap|Line Numbers
  1.  if (document.Form1.Checkbox1.checked)
The script works fine in IE, and has for years. It doesn't work in firefox.
Can anyone help me get this script working in firefox? I repeat. . . I have no Javascript skills, and minimal VB script.

Thanks
ddiabetes
Aug 28 '07 #1
7 2575
pbmods
5,821 Expert 4TB
Heya, DD. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 28 '07 #2
Logician
210 100+
The error console tells me: document.form1 has no properties and takes me to this line:
Expand|Select|Wrap|Line Numbers
  1.  if (document.Form1.Checkbox1.checked)
The script works fine in IE, and has for years. It doesn't work in firefox.
document.Form1 refers to a form by name not id, but I.E. allows either.

Just change the name of the form to 'Form1'.

Strictly speaking, the correct reference to the form by name should be: document.forms.Form1
Aug 28 '07 #3
dmjpro
2,476 2GB
Hello,
I have no javascript knowledge. I am responsible for a website that includes a small amount of javascript, that stops working in firefox. The script begins like this:
Expand|Select|Wrap|Line Numbers
  1. <script = javascript>
  2. }
  3.  
  4. function SameShipping() {
  5.  
  6.  
  7.  
  8. if (document.Form1.Checkbox1.checked)
  9. {    
  10.         document.Form1.shipping_fname.value = document.Form1.fname.value;
  11.         document.Form1.shipping_lname.value = document.Form1.lname.value;
  12.  
  13. <BLAH BLAH>
  14. </script>
The job of the script is to populate the shipping address fields with the billing address data, if the sameshipping checkbox is checked.

The <form> line looks like this:
Expand|Select|Wrap|Line Numbers
  1. <form id="Form1" name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)" action='createaccount.asp?comments=<%=comments & "&shipping=" & shipping%>' method="post">
Here's the sameshipping Checkbox line:
Expand|Select|Wrap|Line Numbers
  1. <INPUT id="Checkbox1" onclick="SameShipping();" type="checkbox" value="ON" name="sameshipping">
The error console tells me: document.form1 has no properties and takes me to this line:
Expand|Select|Wrap|Line Numbers
  1.  if (document.Form1.Checkbox1.checked)
The script works fine in IE, and has for years. It doesn't work in firefox.
Can anyone help me get this script working in firefox? I repeat. . . I have no Javascript skills, and minimal VB script.

Thanks
ddiabetes
Welcome to TSDN.
You have some problems with your code.
1.Why you mentioned URL in the action tag in Form Action?
If you only mention the action tag with a page name then it will work.
And the way of passing fields depends on Get Method or Post Method whatever you will use.
And this is not your problem related but you should not do it.

Now your second problem which is your problem related that is you should write it document.FrontPage_Form1 or document.forms['FrontPage_Form1'] instead of document.form1.
If you want it using form1 ID then you should write document.getElementById('form1').
I think now the point I want to clarify you it is cleared.
So best of luck with your try.

Kind regards,
Dmjpro.
Aug 28 '07 #4
acoder
16,027 Expert Mod 8TB
One other change you could make (though not related to your problem) is to change:[HTML]<script = javascript>[/HTML] to [HTML]<script type="text/javascript">[/HTML]
Aug 28 '07 #5
I've had the exact same problem, in my case I was creating dynamic forms.

I put the following condition before executing the forms:

if (document.formName.inputName)

So in your case try to put this before executing the form code

Expand|Select|Wrap|Line Numbers
  1. if(document.FrontPage_Form1.sameshipping) 
Expand|Select|Wrap|Line Numbers
  1. function SameShipping() {
  2.  
  3. if(document.FrontPage_Form1.sameshipping) {
  4.  
  5.  
  6. if (document.Form1.Checkbox1.checked)
  7.  
  8. {   
  9.  
  10.         document.Form1.shipping_fname.value = document.Form1.fname.value;
  11.  
  12.         document.Form1.shipping_lname.value = document.Form1.lname.value;
  13.  
  14. </script>
Aug 28 '07 #6
Thanks! I got it working! I will apply the other suggestions, as well.
Ddiabetes
Aug 28 '07 #7
acoder
16,027 Expert Mod 8TB
Glad you got it working. Post again if you hit any more problems.
Aug 29 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: torbs | last post by:
I am trying to use the methods in quicktimes plugin, but IE generetes an error. I have tried to use the "document.all" instead of getElementById but the results remain the same. It won't recognise...
3
by: Jon Natwick | last post by:
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()">...
3
by: Bindia | last post by:
I am geetting the error 'document.form1' has no properties. This is my code: <html> <title>Street map concept</title> <!--<script type="text/javascript" src="common.js" ></script>--> <script>...
5
by: Nathan Sokalski | last post by:
I have an ASP.NET application which is giving the following JavaScript error: 'theForm' is undefined However, when I do a View Source one of the <scriptelements is as follows: <script...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.