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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam

    #1

    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.dt d">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Trivia l 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="Multibutt on" type="submit" value="Value 1">This
    multibutton value 1</button><br />
    <button name="Multibutt on" 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
  • adsmart@gmail.com

    #2
    Re: Using multiple button type=&quot;subm it&quot; 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="Multibutt on" type="submit" value="Value 3"><img
    src="http://groups-beta.google.com/groups/img/groups_medium.g if"
    /></button>

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

    does anyone else have similar experiences?

    Comment

    • David Dorward

      #3
      Re: Using multiple button type=&quot;subm it&quot; 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

      Comment

      • Jukka K. Korpela

        #4
        Re: Using multiple button type=&quot;subm it&quot; 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

        Comment

        Working...