[whatwg] non-checked checkbox posting success?

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.

> Does anybody think it would be good to allow a checkbox (and  
> similar controls) to be used in a proper toggle sense?

I do.

> e.g.
>
> <input type="checkbox" name="foo" toggle="true,false" value="on">
>
> where on/off (or setting checked) would toggle the true/false, and any
> values can be used in the toggle attribute:
>
> <label>Click here if you have a dog <input ... toggle = "Dog owner,No
> dogs" value="off" ... ></label>
>
> I'm only attempting to provoke a discussion here, so dont take my code
> and attributes too seriously :-)

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.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/

Received on Monday, 24 July 2006 11:54:58 UTC