Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript error Uncaught TypeError: Property 'forms' of object #<HTMLDocument> is not a funct

Status
Not open for further replies.

gseales

IS-IT--Management
Aug 18, 2009
7
US
thread216-1689833

I am not a javascript programmer but am trying to trouble shoot a problem running on our server that seems similar to the above thread.

In Chrome I cannot login to the application because it stops on the below line with this error message, "Uncaught TypeError: Property 'forms' of object #<HTMLDocument> is not a function ".

Chrome
<script>function SetFocus(){document.forms('FORM').USERNAME.focus();document.forms('FORM').USERNAME.select();}window.onload = SetFocus;</script>



In IE8 I receive the error message, " 'document.forms(...).QueryGUID' is null or not an object" and the code is below. I can login in to the application in IE8, but eventually get kicked back to the login screen.

<script>function SetFocus(){document.forms('FORM').QueryGUID.focus();document.forms('FORM').QueryGUID.select();}window.onload = SetFocus;</script>

Not sure if more info is needed as I am not knowledgeable in Javascript, but spent the entire day looking through the code this is used with and got no where. Thanks for any help.
 
isn't document.forms a collection? so you'd address its members as document.forms[ some item number or the name of the form ].
 
actually I am not sure that addressing an item by its name is standards compliant. so it might not work in all browsers. collection sequence number will work though.
Code:
[b][COLOR=#0000FF]var[/color][/b] frm [COLOR=#990000]=[/color] document[COLOR=#990000].[/color]forms[COLOR=#990000][[/color][COLOR=#993399]0[/color][COLOR=#990000]];[/color]

and of course if you give the form an ID you can easily reference it

Code:
[COLOR=#990000]<[/color]form id[COLOR=#990000]=[/color][COLOR=#FF0000]"myForm"[/color] method[COLOR=#990000]=[/color][COLOR=#FF0000]"post"[/color] action[COLOR=#990000]=[/color][COLOR=#FF0000]"somepage.php"[/color] [COLOR=#990000]>[/color]

[COLOR=#990000]</[/color]form[COLOR=#990000]>[/color]
[COLOR=#990000]<[/color]script type[COLOR=#990000]=[/color][COLOR=#FF0000]"text/javascript"[/color][COLOR=#990000]>[/color]
[b][COLOR=#0000FF]var[/color][/b] frm [COLOR=#990000]=[/color] document[COLOR=#990000].[/color][b][COLOR=#000000]getElementById[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'myForm'[/color][COLOR=#990000]);[/color]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top