Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submitting a form with Javascript

    Hi,

    I've currently got a form setup like so...

    Code:
    <form method="POST" action="/hr/index.php?div=24&admin=add" name="hr" enctype="multipart/form-data">
    ...
    <input type="submit" name="submit" value="Save Changes" />
    </form>
    I've got some Javascript assigned to a span, with this code:
    Code:
     onclick="document.hr.submit();"
    Yet for some reason it's not working, and throws up errors:
    IE7: "Object doesn't support this property or method"
    FF3: "document.hr.submit is not a function" (Firebug)

    Any idea what I'm doing wrong please? I'm really a bit confused by this :/

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Yes, hr.submit refers to the form element having name="submit".
    Change that name to something else, "submit1"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Blimey, I never would of expected that - many thanks for the fix and explanation, really appreciate it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •