|
-
Sep 4th, 2002, 01:08 PM
#1
Thread Starter
Frenzied Member
(JavaScript) What is the correct way to find a form?
What is the correct way to find a form? I have:
Code:
var formObj = eval('document.forms.' + formName)
But this was written some time back (over a year I believe), so was wondering if I needed to correct it.
Thanks,
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Sep 5th, 2002, 03:17 AM
#2
Fanatic Member
forms is part of the DOM. So using...
Code:
syntax : document.forms(objectID/Name)...
document.forms('form1')...
document.forms(1)...
You'll also get away with using document.getElementById('form1') if the form has an id attribute and document.getElementsByName('form1') if name attribute
-
Sep 5th, 2002, 04:28 AM
#3
Frenzied Member
Shouldn't they be square brackets, or can you use standard ones?
-
Sep 5th, 2002, 07:31 AM
#4
Fanatic Member
it works with both but I [] is in the documentation
-
Sep 5th, 2002, 09:52 AM
#5
Frenzied Member
-
Sep 5th, 2002, 09:53 AM
#6
Thread Starter
Frenzied Member
I changed to:
Code:
var formObj = eval(document.forms[formName]);
and it works great 
Thanks,
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|