469,327 Members | 1,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Button submit form

Does anyone know why this doesn't seem to work on certain browsers /
versions?

<form name="formulier" action="script.cgi" method="post">
<a href="#" onClick="document.formulier.submit()"><img src="button.gif"
border="0" ></a>
</form>


Jul 20 '05 #1
1 1440
"Frank" <fs******@hotmail.co> wrote in message
news:40*********************@news.inter.NL.net...
Does anyone know why this doesn't seem to work on certain
browsers / versions?

<form name="formulier" action="script.cgi" method="post">
<a href="#" onClick="document.formulier.submit()"><img
src="button.gif" border="0" ></a>
</form>


Lots of possible reasons:-

1. JavaScript disabled/incapable browsers will not execute the onclick
attribute code at all.

2. The onclick code does not cancel the navigation so if the form has
not been submitted (actually sent) when the navigation specified in the
HREF occurs the browser might be assuming that the user has changed
their mind and stop/cancel the submit to act on the user's second
request (as there is no longer any need to display the result of the
form submission, so why bother sending it).

3. The browser is not making references to named form objects named
properties of the document object (there are no standards that say they
should) so the reference is not being resolved to the form and instead
is generating a JavaScript error.

4. Something else resulting form mark-up or JavaScript not shown above.

But the design is stupid as submitting a form by clicking on an image is
easily achieved using an <input type="image" ... > element. Requiring no
JavaScript at all.

Richard.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by JR | last post: by
1 post views Thread by jrefactors | last post: by
4 posts views Thread by Dmitry Korolyov [MVP] | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.