Jump to content

Is it possible to make an unchecked checkbox pass its value


solarisuser

Recommended Posts

Hello All,

 

Just curious if there is a way to pass a checkbox that is NOT checked with "=> off".  This would be the opposite if a checkbox IS checked, where it is passed with "=> on".

 

Currently, I have a search page that allows users to select a checkbox and clicks the "Send" submit button, the form saves that checkbox value to a session.  When that same search page is refreshed, that checkbox is already checked since the user selected and submitted it.

 

The problem I am trying to tackle is how to let the user "un-check" that box, and click the "Send" submit button, and read from $_POST that it was unchecked.

 

Any Ideas would help.

 

Thanks

Link to comment
Share on other sites

You can try

<form>
<input type="hidden" name="check1" value="no">
<input type="checkbox" name="check1" value="yes"> Yes<br>
<input type="submit" name="submit">
</form>

 

This may or may not work on all browsers. Use with caution.

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.