checkbox 전체 선택 및 삭제

// 
    function  allSelect(){
            $('.td_chk :checkbox').attr('checked',true);
    }
    // 
    function unSelect(){
        $('.td_chk :checkbox').attr('checked',false);
    }
    // 
    function del(){
        var  num =  $(".chkbox:checked").length;   // ( checkbox class .chkbox)
        var  data =  new Array(); // 
        if(num){
            $('.chkbox:checked').each(function(){
                data.push($(this).val());   // 

            })
          if(confirm(' ?'+data)){
              $.ajax({
                  url:'<?php echo site_url(CFG_CMSPATH.'article/delrow')?>',  // CI URL
                  data:({aid:data.join()}), //data.join , 
                  success:function(){
                     window.location.reload();  // , 
                  }
              })
          }
        }
    }

php 코드: 컨트롤러:
 public  function delrow($aid=''){
      if($aid){ // 
          $this->where['aid'] = $aid;
          $this->model->delete($this->where);
          redirect($_SERVER['HTTP_REFERER']);
      }else{
          if(isset($_GET['aid'])):   // 
              $this->where['in_aid'] = $_GET['aid'];
             $this->model->delete($this->where);
          endif;
      }
  }

비고: 자세한 삭제 방법은 모델에 적혀 있습니다. delete from tab where aid in ()

좋은 웹페이지 즐겨찾기