Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使复选框在选中或未选中时携带正确的值_Php - Fatal编程技术网

Php 如何使复选框在选中或未选中时携带正确的值

Php 如何使复选框在选中或未选中时携带正确的值,php,Php,当复选框留空时,我希望它携带值“false”,当复选框被选中时,我希望它携带值“true” 挡风玻璃 加热椅 指标 我在我的一个带有id=“挡风玻璃”的复选框中尝试了这个,但它没有起任何作用 选中该复选框时,它将返回值true;未选中该复选框时,它将返回值false。因此,在数据库中,它将被保存为false或true,而不是像现在这样全部“打开”也许下面的代码将帮助您解决问题 挡风玻璃 加热椅 指标 var挡风玻璃=document.getElementById(“挡风玻璃”); var h

当复选框留空时,我希望它携带值“false”,当复选框被选中时,我希望它携带值“true”

挡风玻璃
加热椅
指标
我在我的一个带有id=“挡风玻璃”的复选框中尝试了这个,但它没有起任何作用


选中该复选框时,它将返回值true;未选中该复选框时,它将返回值false。因此,在数据库中,它将被保存为false或true,而不是像现在这样全部“打开”

也许下面的代码将帮助您解决问题

挡风玻璃
加热椅
指标
var挡风玻璃=document.getElementById(“挡风玻璃”);
var heatedchairs=document.getElementById(“heatedchairs”);
var indicators=document.getElementById(“指标”);
//默认错误
挡风玻璃检查=假;
heatedchairs.checked=false;
指示器。已检查=假;
console.log('默认挡风玻璃---',挡风玻璃已选中);
log('defaultheatedchairs--',heatedchairs.checked);
log('defaultindicators--',indicators.checked);
document.getElementById('register')。onclick=function(){
console.log('单击挡风玻璃---',挡风玻璃已选中);
console.log('clicked heatedchairs--',heatedchairs.checked');
log('clicked indicators-->',indicators.checked);
}
请解释,而不是像现在这样“开着”。也可能是数据库保存代码有问题。那么把它也加在这里,你看到了吗?请修复脚本标记,该标记应该是
,也不应该是
的可能副本
<label for="windscreen"><b>Windscreen</b></label>
        <input class="form-control" id="windscreen" type="checkbox" name="windscreen">

        <label for="heatedchairs"><b>Heated Chairs</b></label>
        <input class="form-control" id="heatedchairs" type="checkbox" name="heatedchairs">

        <label for="indicators"><b>Indicators</b></label>
        <input class="form-control" id="indicators" type="checkbox" name="indicators">

        <input class="btn btn-primary" type="submit" id="register" name="create" value="Sign up">


<script
   function register {
   document.getElementById("windscreen").checked = true;
   document.getElementById("windscreen").checked = false;
   }>
</script>