Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 24th, 2005, 01:15 AM
Adam
Guest
 
Posts: n/a
Default Using multiple button type="submit" elements within a form

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
  #2  
Old July 24th, 2005, 01:16 AM
adsmart@gmail.com
Guest
 
Posts: n/a
Default Re: Using multiple button type="submit" elements within a form

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?

  #3  
Old July 24th, 2005, 01:16 AM
David Dorward
Guest
 
Posts: n/a
Default Re: Using multiple button type="submit" elements within a form

Adam wrote:
[color=blue]
> 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.[/color]

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.
[color=blue]
> What fixes, if any, are there. I really don't want to use input
> type="submit" or input type="image".[/color]

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
  #4  
Old July 24th, 2005, 01:16 AM
Jukka K. Korpela
Guest
 
Posts: n/a
Default Re: Using multiple button type="submit" elements within a form

David Dorward <dorward@yahoo.com> wrote:
[color=blue][color=green]
>> What fixes, if any, are there. I really don't want to use input
>> type="submit" or input type="image".[/color]
>
> 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.[/color]

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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.