[whatwg] non-checked checkbox posting success?

When using checkboxes in forms i find myself doing this

<input type="checkbox" name="foo" value="true">
<input type="hidden" name="foo" value="false">

and retrieving the value from the posted form data a bit like this

if( checkbox.value == "false" )then
	bSomeBool = false;
else	
	bSomeBool = true;


in the "else" case above checkbox.value will equal something along the
lines of "true, false". Does anybody think it would be good to allow a
checkbox (and similar controls) to be used in a proper toggle sense?


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 :-)


Ric Hardacre
http://www.cyclomedia.co.uk/

Received on Monday, 24 July 2006 08:59:07 UTC