W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2005

[whatwg] default action/button for forms

From: Matthew Raymond <mattraymond@earthlink.net>
Date: Fri, 11 Feb 2005 11:52:55 -0500
Message-ID: <420CE2E7.6010405@earthlink.net>
Michael Gratton wrote:
> After looking through the archives, surprised to find that there has
> been no mention of some way to specify the default button/action for a
> form.
> Most browsers behave as the Web Forms 2.0 spec specifies in section 2.3,
> "Changes to existing controls". That is, the first button is used as the
> default. But this is pretty annoying behaviour. In a large form, it is
> common to have several submit buttons and is is just as likely as it is
> not that the first button should be the default.

    Good point.

> As a result, web application developers generally resort to one of two
> kluges: adding a hidden submit button to the form or using JavaScript to
> trap key events or the form submission event.

    Neither ideal, since it's best to have solutions that don't CSS or 
JS support.


> It would be great to see some way of specifying the default button for
> the form in Web Forms 2.0, or some later revision. One way of
> implementing this (and the way I would do it if I was fixing the problem
> using JavaScript) would be to add a "default-action" attribute or
> similar to the form element. This would be an IDREF that specifies the
> id of the default submit button. Eg:
>   <form action="bofh" method="post" default-action="lart">
>     <input type="text" name="who">
>     <input type="submit" id="ignore" name="action" value="Ignore">
>     <input type="submit" id="lart" name="action" value="LART">
>   </form>
> What do you think?

    I'd prefer something like this:

| <form action="http://somesite.com/prog/adduser" method="post">
|   <input type="text" name="who">
|   <input type="submit" name="action" value="Remove">
|   <input default type="submit" name="action" value="Add">
| </form>
Received on Friday, 11 February 2005 08:52:55 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:39 UTC