【发布时间】:2023-03-18 03:43:01
【问题描述】:
这是我的脚本:
HTML 代码:
<script>
function pickIt(pId){
if(document.getElementById(pId).checked==true){
document.getElementById(pId).checked=false;
}else{
document.getElementById(pId).checked = true;
}
submitForm();
return true;
}
</script>
<img src="images/bagua-square.gif" border="0" usemap="#Map2" />
<map name="Map2" id="Map2">
<area shape="rect" coords="201,14,284,100" onclick="pickIt(1);" />
<area shape="rect" coords="202,104,284,190" onclick="pickIt(2);" />
<area shape="rect" coords="202,195,284,283" onclick="pickIt(3);" />
</map>
<div style="display:none;">
<input type="checkbox" id="1" name="box[]" />
<input type="checkbox" id="2" name="box[]" />
<input type="checkbox" id="3" name="box[]" />
</div>
PHP 代码:
<?php
print_r($_POST['box']);
?>
当我点击 box id 1 pickIt() 功能时,将复选框 1 设置为 on。并且 php 显示 array(0=>'on')
但我也想获取未选中的复选框值,以便 php 显示 数组(0=>'on', 1=>'off', 2=>'off')
实际上我想获取所有复选框的状态 on 和 off 因为我在 mysql db 中使用这些 id 来更新记录状态 on 或关闭。 请指导。
【问题讨论】:
标签: php javascript mysql html