Checkbox in Form

3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 17, 2013   (RSS)

By depdesign - July 17, 2013

I am working on a form that applies info to a user account.  Part of the form includes a PRE-CHECKED CHECKBOX that requires a user can un-check if they do not accept.

I have everything working fine, but, here is the issue:

If a user accepts the PRE-CHECKED CHECKBOX and submits then later decides to return to the form and unselect the PRE-CHECKED CHECKBOXand submit, the value in the account remains checked.

From what I've read in the posts is that a unselected checkbox does not send a value which is why its not overwriting the value to be 0.

Is there anything that can be added to the input field that would allow the value to be entered as 0 if a checkbox is unselected?

Here is the code used:

<input name="accept" value="1" checked="checked" type="checkbox" <?php if(@$_REQUEST['accept']){echo "checked='checked'";}?>>

Dan Perez

By depdesign - July 17, 2013

Thanks Daryl, your solution worked perfectly!

Dan Perez