Skip to content

Instantly share code, notes, and snippets.

@jamesfinley
Last active December 20, 2015 10:09
Show Gist options
  • Save jamesfinley/6113418 to your computer and use it in GitHub Desktop.
Save jamesfinley/6113418 to your computer and use it in GitHub Desktop.
The problem with a checkbox field is that it only has one value and that value is only sent when it is checked. Optimally, it would have an on and off value. To compensate for that, I include a hidden field before the checkbox, with the same name, that contains the off value. When the checkbox is checked, the checkbox value is sent. When it is u…
<input type="hidden" name="show_pictures" value="0" />
<input type="checkbox" id="show_pictures_field" name="show_pictures" value="1" />
<label for="show_pictures_field">Show Pictures</label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment