thinkphp 批量删除
1.表单提交数据<formaction="__URL__/deleteSelected"method="post"></form>2.js验证<ahref="#"onclick="delAll()"class="delete">批量删除</a><tdclass="tc"><inputname="id[]"value="<{$voList.txt_id}>"type="checkbox"></td><script>functiondelAll(){varchk_value=[];$('input[name="id[]"]:checked').each(function(){chk_value.push($(this).val());});console.log(chk_value);varsubmit=confirm(chk_value.length==0?'你还没有选择任何内容!':'您是否需要将id'+chk_value+'删除');if(submit){window.location.href="__URL__/deleteSelected/id/"+chk_value;returnfalse;}else{returnfalse;};}</script>3.删除//批量删除publicfunctiondeleteSelected(){$getid=$_REQUEST['id'];//获取选择的复选框的值dump($getid);if(!$getid)$this->error('未选择记录');//没选择就提示信息$getids=implode(',',$getid);//选择一个以上,就用,把值连接起来(1,2,3)这样$id=is_array($getid)?$getids:$getid;//如果是数组,就把用,连接起来的值覆给$id,否则就覆获取到的没有,号连接起来的值//最后进行数据操作,$Result=D("Txt")->delete($id);$say='删除成功';if($Result===false){$this->error('操作失败');}else{$this->success($say);}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。