Results 1 to 6 of 6

Thread: (JavaScript) What is the correct way to find a form?

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    (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.

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    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
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Shouldn't they be square brackets, or can you use standard ones?

  4. #4
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    it works with both but I [] is in the documentation
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  5. #5

  6. #6

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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
  •  



Click Here to Expand Forum to Full Width