例子,js复选框多选删除。
<?php
if("确认删除"){
$num=$_POST['checkbox'];
foreach($num as $v){
$sql="delete from aa where id =".$v;
$aa=mysql_query($sql);
echo "<script language='javascript'>location.href='www.baidu.com';</script>";
}
}
?>
<input type='checkbox' name='checkbox[]' value='值'>
<input type='button' value='全选' onClick="this.value=check('checkbox[]')">
<script>
var checkflag = "false";
function check(fieldName) {
var field=document.getElementsByName(fieldName);
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;
}
checkflag = "true";
return "全选";
}else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "全选";
}
}
</script>