Solved

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

Posted on 2003-11-19
2
915 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
Comment Utility
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
Comment Utility
Well, that did it. Thanks! I'm sure that was an easy 100 points. :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now