基本上,我可以获得在框被勾选 (= 1) 时适用的值,但我无法在未选中时发送默认值 0。
<input type="checkbox" name="post_friend" value="1">
我四处搜索,有人建议设置一个隐藏的复选框,但它对我不起作用。
<input type="hidden" name="post_friend" value="0">
最佳答案
你不能做这样的事情吗?
$checkbox = isset($_POST['post_friend']) ? $_POST['post_friend'] : 0 ;
所以如果复选框被选中,变量为1。如果没有,变量赋值为0
关于php - 如果未选中,则尝试设置默认复选框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17688968/