Solved

Error: document.FormName.FieldName is null or not an object. What the..?!

Posted on 2003-11-19
2
922 Views
Last Modified: 2008-02-01
Hi,
   I have a little form that has 3 textboxes and one textarea. I have previously run a query in ColdFusion to get the data that will populate these text boxes. When the form loads initially, I want the first record from the query to be displayed in the text boxes. With this form there are also 'left' and 'right' buttons to be used to navigate through the record set. There is also an update button so users can update the records. To make the data available in Javascript I output each element to a different array. There is no problem with any of this part of the form. However, when I try to set the values of each text box I get the following  error:  "document.FormName.FieldName is null or not an object. " Where FormName is the name of the form and FieldName is the name of the specific textbox. for example:

document.UpdateUserForm.EditFirstName.value = FirstNameArray[CurrentCount];
document.UpdateUserForm.EditLastName.value = LastNameArray[CurrentCount];
etc...

but this returns the error. So is there a problem with how I am referencing this? Or does it have to do with the form not being 'submitted' initially? Or something else? Thanks for your help!
0
Comment
Question by:Roentgen
2 Comments
 
LVL 25

Accepted Solution

by:
devic earned 100 total points
ID: 9783665
hi Roentgen,

move this:
document.UpdateUserForm.EditFirstName.value = FirstNameArray[CurrentCount];
document.UpdateUserForm.EditLastName.value = LastNameArray[CurrentCount];

after </form>

OR

make function and call it with onload event:
===============================
<body onload=makedefaults();>
<script>
function makedefaults()
{
    document.UpdateUserForm.EditFirstName.value = FirstNameArray[CurrentCount];
    document.UpdateUserForm.EditLastName.value = LastNameArray[CurrentCount];
}
</script>
0
 
LVL 1

Author Comment

by:Roentgen
ID: 9787378
Well, that did it. Thanks! I'm sure that was an easy 100 points. :)
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

685 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