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.

No related posts.

Tagged: ,

§ One Response to “unchecked checkbox not in $_POST”

  • Kevin Halberg says:

    I am seeing with FireFox that both are sent when the checkox is checked. Any fix for that?

  • § Leave a Reply

What's this?

You are currently reading unchecked checkbox not in $_POST at westworld: a webmasters best friend.

meta