[whatwg] non-checked checkbox posting success?

Ric Hardacre ric at hardacre.org
Tue Jul 25 00:48:34 PDT 2006

Hash: SHA1

Michel Fortin wrote:
> Le 24 juil. 2006 à 11:59, Ric Hardacre a écrit :
>> When using checkboxes in forms i find myself doing this
>> <input type="checkbox" name="foo" value="true">
>> <input type="hidden" name="foo" value="false">
> I'm doing the same right now. I have a list of checkbox which can be
> either on or off for each of my elements, and I can't rely on the input
> being absent meaning it is off because the list is paginated and may not
> show all elements at once. That hidden input trick is quite handy.

> What about adding a "value-unchecked" attribute instead:
>     <input type="checkbox" name="foo1"
>            value="true" value-unchecked="false">
> In the absence of a "value-unchecked" attribute, an unchecked checkbox
> sends no input, just like the checkbox we have today.

Yes, something like that would do it. I realised that you can just use
two radio buttons in a group to achieve the same affect, or a two-choice
select but the checkbox is in many instances (apart from sometimes say,
agreeing with terms and conditions statements) the logical field to use.

from the current spec:

For checkbox and radio form controls, the value  attribute defaults to
the literal string on, so that if the value content attribute is not
specified then the value DOM attribute (and the value used for
submission when the controls are checked) is "on". For other controls
the default is the empty string.

so we are already providing exceptional rules for the checkbox element.

Ric Hardacre
Version: GnuPG v1.4.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the whatwg mailing list