?
Solved

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

Posted on 2003-03-05
11
Medium Priority
?
241 Views
Last Modified: 2008-02-01
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
Comment
Question by:dlsmart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 200 total points
ID: 8075304
Okay, run your page in explorer, choose view source, and then paste what you get here.

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8075317
If the controls are on the same form, you can also try using this.form.PubTot1.value='40.00';

Fritz the Blank
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8075569
In any case,
document.forms['ordform'] is needed to reference the form cross-browser
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dlsmart
ID: 8088996
Hmmm? Frontpage actually changed the form name.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8089022
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8091305
So?
0
 

Author Comment

by:dlsmart
ID: 8091667
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8091704
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
 
LVL 1

Expert Comment

by:Computer101
ID: 8091833
grade changed as requested

Computer101
E-E Admin
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8091864
Thank you to both!!

Fritz the Blank
0
 

Expert Comment

by:flukesh
ID: 8327764
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question