By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 2,498 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

Using multiple button type="submit" elements within a form

P: n/a
Hey guys,

I've decided to stop banging my head against the wall and just ask you
guys for the answer. I can't seem to find it.

I have a form in which I have multiple submit buttons; only, I'm using
button tags, not input tags to do it. It seems that IE6 is treating
all the button elements as being successful on submit. This is, to say
the least, surprising since the Spec is pretty clear that it should.

To test this, i created the following trivial HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Trivial Form Submit Test</title>
</head>

<body>
<form action="#" method="get">
<label>Field 1 <input name="field1" /></label><br />
<label>Field 2 <input name="field2" /></label><br />
<label>Field 3 <input name="field3" /></label><br />
<button name="Button1" type="submit" value="button 1">This is
button 1</button><br />
<button name="Button2" type="submit" value="button 2">This is
Button 2</button><br />
<button name="Multibutton" type="submit" value="Value 1">This
multibutton value 1</button><br />
<button name="Multibutton" type="submit" value="Value 2">This
multibutton value 2</button>
</form>
</body>
</html>

In IE I get the name/value pairs for all the buttons, as well as the
input vaules.

What fixes, if any, are there. I really don't want to use input
type="submit" or input type="image".

Thanks
Adam
Jul 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Let me add an addendum. IE seems also to submit the content of the tag,
not its value.

When I added:
<button name="Multibutton" type="submit" value="Value 3"><img
src="http://groups-beta.google.com/groups/img/groups_medium.gif"
/></button>

To my utter horror, the value that was sumbitted was the image tag URL
encoded.

does anyone else have similar experiences?

Jul 24 '05 #2

P: n/a
Adam wrote:
I have a form in which I have multiple submit buttons; only, I'm using
button tags, not input tags to do it. It seems that IE6 is treating
all the button elements as being successful on submit.
Yes, its a known bug in that excuse for a browser. You'd think they could
fix it with all the service packs that keep coming out for it.
What fixes, if any, are there. I really don't want to use input
type="submit" or input type="image".


That's about your only choice. You can use different names if you want to
reuse the same value - its more work to test on the server side, but about
the only way to deal with MSIE.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #3

P: n/a
David Dorward <do*****@yahoo.com> wrote:
What fixes, if any, are there. I really don't want to use input
type="submit" or input type="image".


That's about your only choice. You can use different names if you
want to reuse the same value - its more work to test on the server
side, but about the only way to deal with MSIE.


There would _still_ be the problem that there is no definition of what
should happen when the user hits Enter in a text input field.
And browsers vary in their interpretations.

The really safe way is to have one input type="submit" and handle the
rest with other fields (other than any kind of submit fields). Then the
browser differences won't matter. This should at least the the first
alternative to be considered. You can add e.g. a set of radio buttons
for choosing the action to be carried out by the form handler, rather
than using different submit buttons for such a choice.

If this is regarded as impossible, you probably need to expect that a
browser will behave as if the _first_ button were used, when the form
is submitted by hitting Enter in a text input field. And how would you
handle that? You won't know whether the use accidentally hit Enter or
really used the first input button. So you might end up with adding a
dummy first button for that purpose. Rather artificial.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.