永利手机在线登录 平台首页-罗湖区幼儿园招生2019

首页

AD联系:507867812

永利手机在线登录 平台首页

时间:2019-11-12 07:36:54 作者:奥斯卡娱乐场压大小技巧 浏览量:29058

永利手机在线登录 平台首页PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结,见下图

PHP ajax+jQuery 实现批量删除功能实例代码小结

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结,见下图

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

,如下图

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

PHP ajax+jQuery 实现批量删除功能实例代码小结

如下图

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

,如下图

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结,见图

永利手机在线登录 平台首页PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结。

PHP ajax+jQuery 实现批量删除功能实例代码小结

永利手机在线登录 平台首页PHP ajax+jQuery 实现批量删除功能实例代码小结

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

1.

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

2.

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

3.

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

4.

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

PHP ajax+jQuery 实现批量删除功能实例代码小结PHP ajax+jQuery 实现批量删除功能实例代码小结。永利手机在线登录 平台首页

展开全文
相关文章
bbin平台大全上seo大牛优化网

PHP ajax+jQuery 实现批量删除功能实例代码小结

河内5分彩五星个位走势

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

maya登录地址18

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

哪个国家有中国的博彩公司

PHP ajax+jQuery 实现批量删除功能实例代码小结....

天平 棋牌 信誉 forum-

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

相关资讯
澳门赌场那间的好赢钱

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

必发365手机登录官

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

澳门威尼斯人357.cc

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

金阳二手房 maya下载

目录结构

piliangshan.php

<?php require_once './db_conn.php'; $sql = "select * from user"; $result = mysqli_query($conn, $sql);?><html lang="zh-CN"><head> <meta charset="UTF-8"> <title>全选演示</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" type="text/css" href="./static/bootstrap.min.css" rel="external nofollow" > <script src="./static/jquery.js"></script> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"></head><body> <form enctype="multipart/form-data" method="post"> <div class="bs-example" data-example-id="simple-table" style="padding-left: 30px;"> <table class="table" id="J-dl"> <a href="javascript:void(0);" rel="external nofollow" class="btn btn-danger" onclick="selectAll()" title="删除选定数据" style="font-weight:normal">批量删除</a> <thead> <tr> <th><input type="checkbox" id="J-all" class="ckb"></th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <th><input type="checkbox" class="ck" id="ck-1" value="'.$row['id'].'"></th> <th scope="row">'.$row['id'].'</th> <td>'.$row['username'].'</td> <td>'.$row['sort'].'</td> </tr>'; } ?> </tbody> </table> </div> </form> <script> (function () { var $all = $('#J-all'); var $dl = $('#J-dl'); // 绑定全选按钮点击事件,让下面所有的复选框是跟全选的一样 $all.on('click', function () { $dl.find('.ck').prop('checked', !!this.checked); }); // 绑定点击所有的复选框,点击的时候判断是否页面中全选了 $dl.find('.ck').on('click', function () { // 我只是喜欢用filter(fn),用选择器也行 // 查找没有选择的元素 var $unSelectedElem = $dl.find('.ck').filter(function () { return !this.checked; }); // 如果有没有选中的,则让全选的取消 if ($unSelectedElem.length) { $all.prop('checked', false); } else { $all.prop('checked', true); } }); })(); </script> <script type="text/javascript"> function selectAll() { var ids = ''; $(".ck").each(function() { if ($(this).is(':checked')) { ids += ',' + $(this).val(); //逐个获取id值,并用逗号分割开 } }); ids = ids.substring(1); // 进行id处理,去除第一位的逗号 if (ids.length == 0) { alert('请至少选择一项'); } else { if (confirm("确定删除选中的?")) { $.ajax({ type: "post", url: "piliangdo.php", data: { ids:ids }, success: function(data) { if(data.trim()=="yes") { alert("删除成功"); location.reload() //刷新页面 } else { alert("删除失败"); } } }); } } } </script></body></html>

piliangdo.php

<?php header("content-type:text/html;charset='utf-8'"); require_once './db_conn.php'; $ids = trim($_POST['ids']); $ids = explode(',', $ids); foreach ($ids as $key => $val) { $del_sql = "DELETE FROM `user` WHERE id = '$val'"; $result = mysqli_query($conn, $del_sql); } if ($result) { echo "yes"; } else{ echo "no"; }?>

总结

以上所述是小编给大家介绍的PHP ajax+jQuery 实现批量删除功能实例代码小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

....

热门资讯