Solved

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

Posted on 2003-11-19
2
917 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

863 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

18 Experts available now in Live!

Get 1:1 Help Now