• Think5之ajax批量删除数据功能


    //批量删除学员信息
    	public function deleteMany() {
    
    		  $id = input('post.');  //判断id是数组还是一个数值 
    		  if(is_array($id)){ 
    			 foreach($id['data'] as $v){
    			  	$ids[] = $v['value'];
    			} 
    		    $where = 'id in('.implode(',',$ids).')';  
    		  }else{  
    		   $where = 'id='.$id; 
    		  }  
    		  $list=model("students")->where($where)->delete();  
    		  if($list==true) {
    		    $this->success("成功删除{$list}条!"); 
    		  }else{   
    		    $this->error('批量删除失败!');  
    		  } 
        }
    

    <a href="javascript:;" id="del" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>

    {volist name='studentsList' id='vo'}
    <th width="15"><input type="checkbox" class="all" ></th>
    <th width="30">ID号</th>
    <th width="30">姓名</th>
    
    
    <td><input name='id[]' type="checkbox" value="{$vo.id}"></td>
    <td>{$vo.id}</td>
    <td>{$vo.edu_name}</td>
    
    {/volist}
    

      

    // 删除操作js
      $('#del').click(function() {
        if($(':checked').size() > 0) {
          layer.confirm('确定要删除吗?', {
            btn: ['确定','取消'], //按钮
            shade: false //不显示遮罩
          }, function(){
            $.post("{:url('students/deleteMany')}",{data: $('form').serializeArray()}, function(data) {
              layer.msg('恭喜,已批量删除', {icon: 1, time: 1000});
              setTimeout(function() {
                location.reload();
              }, 1000);
            });
          }, function(){
            layer.msg('取消了删除!', {time: 1000});
          });
        } else {
          layer.alert('没有选择!');
        }
      });
    

      

  • 相关阅读:
    神奇的HTML5画图应用
    Eclipse REST 库使用
    在应用中使用Ext Loader
    新浪微博XSS攻击事件
    数字图像处理空间变换
    安装制作不用愁—Wise installation入门教程
    ExtJS 4中自定义Grid列标题的对齐方式
    页面的兼容性从认识<!DOCTYPE>开始
    ExtJS 4.1有什么值得期待?
    ExtJS应用架构设计(二)
  • 原文地址:https://www.cnblogs.com/qinglin/p/8692026.html
Copyright © 2020-2023  润新知