//将数据转换成字符串 foreach($check as $str){ $idstr .= $str.","; } //去掉生成的字符串最后多出来的一个"," $idstr = substr($idstr,0,-1);$sql ="update table set area1=xx where id in(".$idstr.")"; mysql_query($sql);
前台保存到隐藏域中如下 var strchoice=""; if(CheckKey.checkbox[0]==undefined){ if(CheckKey.checkbox.checked==true){ strchoice=CheckKey.checkbox.value; }else{ strchoice=""; } }else{ for(i=0;i< CheckKey.checkbox.length;i++){ if (CheckKey.checkbox[i].checked==true){ strchoice=strchoice+CheckKey.checkbox[i].value+","; } } strchoice=strchoice.substring(0,strchoice.length-1); }
<script language="javascript">
function checkAll(){
var iLeng = document.form1.check_id.length;
for(i=0;i<iLeng;i++){
if(document.getElementById("checkAll").checked){
document.form1.check_id[i].checked = true;
}
else{
document.form1.check_id[i].checked = false;
}
}
}
</script>
这样写似乎有错误
document.form1.check_id[i].checked = true;
}
然后在js操作这个对象就可以了
var obj=document.getElementsById("check_id[]");
http://www.kuomart.com/blog
$pig = $_POST['check_id'];
echo $pig;输出为:array
怎么办?
现在你的$pig已经是数组了,里面的元素就是选中所有的值,该怎么处理怎么处理了撒
看到什么了?
LZ认为mysql会如何操作这样的数据呢 ?
呵呵~~~
foreach($check as $str){
$idstr .= $str.",";
}
//去掉生成的字符串最后多出来的一个","
$idstr = substr($idstr,0,-1);$sql ="update table set area1=xx where id in(".$idstr.")";
mysql_query($sql);
var strchoice="";
if(CheckKey.checkbox[0]==undefined){
if(CheckKey.checkbox.checked==true){
strchoice=CheckKey.checkbox.value;
}else{
strchoice="";
}
}else{
for(i=0;i< CheckKey.checkbox.length;i++){
if (CheckKey.checkbox[i].checked==true){
strchoice=strchoice+CheckKey.checkbox[i].value+",";
}
}
strchoice=strchoice.substring(0,strchoice.length-1);
}