标签:
//HTML
<form method="post" action="{:U(‘Home/Qrcode/alldel‘)}" name="form1" id="form1" onsubmit="return confirm(‘确定要全部删除吗?‘);">
<input type="checkbox" class="ng-pristine ng-valid" value="{$vo.id}" name="check[]"></td>
<input type="checkbox" class="ng-pristine ng-valid" onclick="checkall(‘all‘)" >//点击选择
<button type="submit" class="btn btn-default ng-binding">批量删除</button>
</form>
//PHP
public function alldel(){
$check=array();
$check=I("post.check");
if($check==""){
$this->error("请选择要删除的信息");
}else{
$str=implode(‘,‘, $check);
$r=M("qrcode")->where(array(‘id‘=>array(‘in‘,$str)))->delete();
if($r){
$this->success("删除成功!",__APP__."/Home/Qrcode/index",2);
}else{
$this->error("删除失败!",__APP__."/Home/Qrcode/index");
}
}
}
//JS
<script type="text/javascript">
function checkall(t){
var es = document.form1.elements;
for(var i=0;i<es.length;i++){
if(es[i].type == ‘checkbox‘ ){
if(t == ‘all‘){
es[i].checked = !es[i].checked;
}
}
}
}
</script>
标签:
原文地址:http://www.cnblogs.com/www-xiaobo-com/p/5545190.html