<td><input type="checkbox" name="bb" value="{{$v->id}}"> {{$v->id}}</td>
<button id="pi">批删</button>
//批量刪除
$(document).on("click","#pi",function () { nam=document.getElementsByName("bb"); str=""; for (i=0;i<nam.length;i++){ if (nam[i].checked==true){ str+=","+nam[i].value; } } id=str.substr(1); $.ajax({ url:"shan", type:"post", dataType:"json", data:{ id:id }, success:function (data) { console.log(data); if (data==1){ location.href="" } } }) })
function shan(req $req){ $id= $req->post("id"); $id=explode(",",$id); foreach ($id as $k=>$v){ $res= DB::table("poker")->delete($v); } return 1;}
原文地址:https://www.cnblogs.com/azzy/p/11748799.html
时间: 2024-08-30 18:07:25