发布:2023/12/7 15:17:48作者:大数据 来源:大数据 浏览次数:473
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<script> function del(id) { if (confirm("确定要删除此吗?")) { $.ajax({ type: "POST", url: "MailboxMessage/Delete/" + id, success: function (data, state) { alert("删除成功!"); window.location = "MailboxMessage"; }, error: function (data, state) { alert("删除失败!"); } }); } } function del_all() { var ids = document.getElementsByName("ids"); var arrIds = ""; //alert(ids[0].value); var n = 0; for (var i = 0; i < ids.length; i++) { if (ids[i].checked == true) { arrIds += ids[i].value + ","; n++; } } if (n==0) { alert("请选择要删除的信息"); return; } arrIds = arrIds.substr(0, arrIds.length-1); //alert(arrIds); console.log(arrIds); if (confirm("确定要删除此吗?")) { $.ajax({ type: "POST", url: "MailboxMessage/DeleteAll/" , data: { ids: arrIds }, success: function (data, state) { alert("删除成功!"); window.location = "MailboxMessage"; }, error: function (data, state) { alert("删除失败!"); } }); } } function checkall() { var checkall = document.getElementById("checkall").checked; var ids = document.getElementsByName("ids"); if (checkall) { for (var i = 0; i <ids.length; i++) { ids[i].checked = 1; } } else { for (var i = 0; i <= ids.length; i++) { ids[i].checked = 0; } } } </script> |
以上是全选与jquery删除操作,删除操作有两种实现办法:一种是jquery,另一种是form分别如下controller:
jquery提交过来的是ids的1,2,3这样的串
[HttpPost]
public IActionResult DeleteAll(string ids)
{
return Ok();
}
//form提交过来ids为数组
[HttpPost]
public IActionResult DeleteAll(string[] ids)
{
return Ok();
}
以上是.net core 批量删除操作实例
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4