form 中checkbox批量全選操作
<a href="http://blog.51cto.com/attachment/201302/124713349.jpg" target="_blank"></a>
<?php
if(isset($_POST["delete"]) && isset($_POST["del_id"])){
$ids = array();
$ids = $_POST['del_id'];
$update_page=$_POST['update_page'];
include("conn.php");
if($ids){
foreach($ids as $id){
$sql05="update `table` set `is_verify`='1' where `id`='$id';";
mysql_query($sql05,$conn);
//$tmp[] = intval($id);
}
//$ids = $tmp;
}
//$ids = implode(',',$ids);
echo "<script>alert('批量稽核通過成功!');window.location='list.php?page=".$update_page."'</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>form批量操作</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="ddaccordion.js"></script>
<script type="text/javascript">
//Initialize Arrow Side Menu:
ddaccordion.init({
headerclass: "menuheaders", //Shared CSS class name of headers group
contentclass: "menucontents", //Shared CSS class name of contents group
revealtype: "clickgo", //Reveal content when user clicks or onmouseover the header? Valid value: "click", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["unselected", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: 500, //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
})
</script>
function CheckAll(delid,checkMoreId){
for(i=0;i<delid.length;i++){
delid[i].checked = true;
if(checkMoreId.checked ==false){
for(j=0;j<delid.length;j++){
delid[j].checked = false;
}
//判斷使用者是否選擇了要删除的記錄,如果是,則提示“是否删除”;否則提示“請選擇要删除的記錄”
function checkdel(delid,formname){
var flag = false;
if(delid[i].checked == true){
flag = true;
break;
if(!flag){
alert("請選擇要稽核的文檔!");
return false;
else{
if(confirm("确定要稽核通過嗎?")){
formname.submit();
function delOrtrue()
{
if(confirm("确定要稽核通過這條記錄嗎?"))
{
return true;
}
else
return false;
</head>
<body>
<form action="" method="post" name="check">
<table>
<tr>
<td><input type="checkbox" name="del_id[]" value="1" id="del_id" />one</td>
</tr>
<td><input type="checkbox" name="del_id[]" value="2" id="del_id" />two</td>
<td><input type="checkbox" name="del_id[]" value="3" id="del_id" />three</td>
<td>
<input type="checkbox" name="role_id" id="selectAll" onclick="CheckAll(del_id,selectAll)" value="2"/>全選
<input type="submit" name="delete" value="批量通過稽核" onclick="if(checkdel(del_id,'check')){return true;}else{return false;};"< /span> />
</td>
</table>
</form>
</body>
</html>
源碼下載下傳位址:
<a href="http://down.51cto.com/data/679335" target="_blank">http://down.51cto.com/data/679335</a>
本文轉自許琴 51CTO部落格,原文連結:http://blog.51cto.com/xuqin/1131653,如需轉載請自行聯系原作者