[thelist] Custom Image Button Problem

Christian Heilmann codepo8 at gmail.com
Thu Dec 29 12:46:12 CST 2005


> I'm trying to create a dropdown jump menu, but am having a hard time
> substituting an image for a default button. I thought it would be very
> easy to do, so I'm bewildered as to why the form keeps breaking when I
> use <input type="image"...>, yet works fine when I use <input
> type="button"...>. Any thoughts? Thanks for any help.

Input type image submits the form, input type button does not. This is
why your JavaScript has no time to execute before the form gets
submitted.
Even worse, your form now will not be submittable without JavaScript,
which is a big usability and accessibility problem.

Use input type image and a real server side solution to enable the
form to work without JavaScript. Then add a "return false" to the end
of your onclick call, and it will not be sent to the server when a
user with JavaScript enabled clicks it.

Example:
http://www.onlinetools.org/articles/unobtrusivejavascript/chapter1.html
Under "6. Keep effects mouse independent"

HTH
Chris

--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/



More information about the thelist mailing list