這是我的腳本:得到檢查和未選中的複選框重視
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']);
?>
當我點擊框ID 1 的PICkit()功能打開復選框1至對。並且php顯示數組(0 =>'on')
但是我也想獲得checkbox的值,這些值不會被檢查,因此php會顯示 array(0 =>'on',1 ='off' ,2 =>「關閉」)
其實我想用自己的狀態所有的複選框上和關閉因爲我用這些ID在MySQL數據庫對或關閉更新記錄狀態。請指導 。
嗯......稍微靠近一點。它的意思是我必須先寫兩個sql查詢來更新所有記錄狀態才能設置,然後只爲那些在數組中的行設置狀態。 ( – 2012-03-21 15:21:54
嗯,不,你不知道, – Quentin 2012-03-21 15:23:29
謝謝你哥們,你已經解決了我的問題:) – 2012-03-21 16:26:52