solarisuser Posted April 25, 2007 Share Posted April 25, 2007 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 https://forums.phpfreaks.com/topic/48559-is-it-possible-to-make-an-unchecked-checkbox-pass-its-value/ Share on other sites More sharing options...
benjaminbeazy Posted April 25, 2007 Share Posted April 25, 2007 if(!$_POST['checkbox']){ echo "checkbox not checked"; } Link to comment https://forums.phpfreaks.com/topic/48559-is-it-possible-to-make-an-unchecked-checkbox-pass-its-value/#findComment-237775 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2007 Share Posted April 25, 2007 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 https://forums.phpfreaks.com/topic/48559-is-it-possible-to-make-an-unchecked-checkbox-pass-its-value/#findComment-237780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.