zoukankan      html  css  js  c++  java
  • 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('没有选择!');
        }
      });
    

      

  • 相关阅读:
    NodeJS旅程 : module 不可忽略的重点
    NodeJS旅程 : Less
    NodeJS旅程 : express
    新的旅程:NodeJS
    活用命令模式
    20145226《信息安全系统设计基础》第0周学习总结
    20145226夏艺华 《Java程序设计》第1周学习总结
    学习 MySQL-DBA常用SQL汇总
    关于旗舰店直通车的由来
    学习 Mysql
  • 原文地址:https://www.cnblogs.com/qinglin/p/8692026.html
Copyright © 2011-2022 走看看