unchecked checkbox not in $_POST

January 20th, 2009 § 1

Iamcam posted a good hack on his blog. It makes your unchecked checkboxes show up in the $_POST on the server.
It’s very simple and doesn’t need javascript.

<input type="hidden" name="box1" value="0" />
<input type="checkbox" name="box1" value="1" />

If the checkbox is not checked then the value of the hidden input is submited, else the value of the checkbox.

Checkboxes in Prototype

October 9th, 2008 § 4

observing:
$(’mycheckbox’).observe(’click’, function(e){alert(’checked = ‘ + this.checked);});

setting throught scripting:
$(’mycheckbox’).checked = true;
$(’mycheckbox’).setAttribute(’checked’, true);
$(’mycheckbox’).setValue(”); // will un-check/null value
$(’mycheckbox’).setValue(’anything’); // will check/on value
$(’mycheckbox’).click(); // will toggle the checkbox

Where Am I?

You are currently browsing entries tagged with checkbox at westworld: a webmasters best friend.