Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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 demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

806 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