jq php 全选及单个处理

只是简单记录一下怕下次用到 复制上来的代码有点乱,建议复制到编辑器里看吧!
jq php 全选及单个处理_第1张图片
html:
表单:

 
method="get" action="{newe:U(doAudited)}"> type="hidden" name="passlist" id="passlist">
单选框:
 <td class="text-left">                                                  <div><a href="{newe:U('doAudited',array('id'=>$vo['id']))}"><button class="tc-15-btn  m ">通过button>a>div>
 td>

<td class="text-left"> <div>                                           
<label class="form-ctrl-label"><input name="pass" id="pass_{newe$vo.id}" class="tc-15-checkbox Remind_time"  type="checkBox"   onclick="pass_change('{newe$vo.id}')">label>
 div>
td>

js:

$("#checkAll").click(function(){
        var str='';
        if($(":checkbox[name='pass']").prop('checked')){
             $(":checkbox[name='pass']").prop('checked',false);
             $(this).text('全选');
             $("#passlist").val('');
         }else{
              $(":checkbox[name='pass']").prop('checked',true);   
              $(this).text('取消全选');
              $(":checkbox[name='pass']").each(function(){  
                    if($(this).is(":checked")){
                        str +=$(this).prop('id').substring(5) +",";
                    }  
            });
             $("#passlist").val(str);
        }
    });
    function pass_change(id){
        var passstr=$("#passlist").val();
        if($('#pass_'+id).is(':checked')){
                $('#passlist').val(passstr+id+',');
        }else{
            $('#passlist').val(passstr.replace((id+','),''));
  }
}

php:

public function doAudited(){
            $id = I('get.id');
            $action['id'] = $id;
            $passlist = I('get.passlist');
            if($passlist){
                $action['id'] = array('in',substr($passlist,0,-1));
            }
            $res = M('ushop_list')
                ->where(array('cid'=>$this->cid,$action))
                ->save(array('status'=>1));
            if($res){
                $this->success('处理成功');
            }else{
                $this->error('处理失败');
            }

    }

你可能感兴趣的:(jq,php)