• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Javascript Error: 'document.form.element' is null or not an object

I have a form "ordform" with a text entry field named "PubTot1". I have a checkbox with code for "onclick" that looks like this:

<input type="checkbox" onclick="javascript:if   (this.checked) {document.ordform.PubTot1.value='40.00';}
else {document.ordform.PubTot1.value='0.00';} Total();" name="NMemSoft" value="ON">

The PubTot1 field is defined as:
<input type="text" name="PubTot1" size="10" value="0.00">

I'm developing in Frontpage 2002, when I use the "Preview" tab in Frontpage this piece of code works fine. But when I save the page and open the page in IE6 or Netscape 7, I get an error:
'document.ordform.PubTot1' is null or not an object

Anyone have some help. This is driving me crazy.

Don
0
dlsmart
Asked:
dlsmart
1 Solution
 
fritz_the_blankCommented:
Okay, run your page in explorer, choose view source, and then paste what you get here.

Fritz the Blank
0
 
fritz_the_blankCommented:
If the controls are on the same form, you can also try using this.form.PubTot1.value='40.00';

Fritz the Blank
0
 
ahosangCommented:
In any case,
document.forms['ordform'] is needed to reference the form cross-browser
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
dlsmartAuthor Commented:
Hmmm? Frontpage actually changed the form name.
0
 
fritz_the_blankCommented:
Why the grade of B then? My advice revealed the problem, did it not? FrontPage does all manner of "helpful" things and I suspected that this was happening to you, hence my advice to use this.form to reference your object.

Fritz the Blank
0
 
fritz_the_blankCommented:
So?
0
 
dlsmartAuthor Commented:
I didn't know I gave a B grade. I'm new to the site and haven't figured out the whole interface, yet. How do I change it?
0
 
fritz_the_blankCommented:
You can do so by asking a question worth 0 points in the community support section (http://www.experts-exchange.com/Community_Support/). Please paste the URL of this question in the body of your request.

Fritz the Blank

0
 
Computer101Commented:
grade changed as requested

Computer101
E-E Admin
0
 
fritz_the_blankCommented:
Thank you to both!!

Fritz the Blank
0
 
flukeshCommented:
One other thing that has not been mentioned is that in Netscape (specifically v.7), you must have a < HTML > and < BODY > tags surrounding the script in question. alert(document.forms) for example, will return "undefined" unless you surround the script with a BODY tag. Then, reference the form the way "Ahosang" posted.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now