Scripsit Steven Saunderson:
>>><form name='submit3' action='http://my.com/cart.cgi' method='post'>
<input type='image' src='advertisement.gif' value='Buy and Download
Now' name='add_to_cart'>
</form>
...
>I thought 'image' functioned as a submit button. Perhaps it isn't
widely supported.
It's widely supported - widely inconsistently, with different quirks and
oddities. See
http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html
which is very dusty but perhaps suitable in a context where someone
worries about Netscape.
I've just tested using Opera and for the 'image' above it would
include '&add_to_cart.x=0&add_to_cart.y=0' in the GET array
(presumably the same for POST). But there is no
'&add_to_cart=whatever' and this makes it different from a submit
button.
That's the "classical" browser behavior. Newer implementations include
the name=value pair, too. The specifications are, as usual, fairly
obscure.
There's the simple solution
<input type="submit" value="Buy">
and this should at least be used in prototypes and debugging, to
distinguish all the problems caused by image submit buttons from other
problems.
Regarding the name=value pair from a submit button (normal or image),
don't count on it. Mostly, a single form should only contain one submit
button to avoid confusion or, in some cases, two or more _equivalent_
submit buttons. The choice between different actions should be made in
some other way, e.g. radio buttons.
The idea of having different buttons for different actions in the same
form, like "Buy" and "Get info", sounds nice, but it fails to work in
general, due to implementation faults. For example, what happens when
the user types text in a text input field and hits Enter, using a
browser where that causes form submission?
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/