...

View Full Version : Submitting a form with Javascript



blizeH
10-10-2008, 03:36 PM
Hi,

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


<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:

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 :/

abduraooft
10-10-2008, 04:18 PM
Yes, hr.submit refers to the form element having name="submit".
Change that name to something else, "submit1"

blizeH
10-10-2008, 05:11 PM
Blimey, I never would of expected that - many thanks for the fix and explanation, really appreciate it :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum