form 中checkbox批量全选操作
- <?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
- //do nothing
- }
- })
- </script>
- <script type="text/javascript">
- 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;
- for(i=0;i<delid.length;i++){
- 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;
- }
- }
- </script>
- </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>
- <tr>
- <td><input type="checkbox" name="del_id[]" value="2" id="del_id" />two</td>
- </tr>
- <tr>
- <td><input type="checkbox" name="del_id[]" value="3" id="del_id" />three</td>
- </tr>
- <tr>
- <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>
- </tr>
- </table>
- </form>
- </body>
- </html>
×××地址:
转载于:https://blog.51cto.com/xuqin/1131653