六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 184|回复: 0

一个简单的全选和批量处理的js判断

[复制链接]

升级  44%

4

主题

4

主题

4

主题

童生

Rank: 1

积分
22
 楼主| 发表于 2013-1-29 08:51:54 | 显示全部楼层 |阅读模式
function updateStatusBatch(type) {
           
            var str= new Array();
            var msg="";
            var b=false;
            //根据name取被选中的值
            $("[name='checkbox']:checked").each(function(i){
                str[i] = $(this).val();
           //判断状态根据状态设定提示信息
                if(type==2){
                    if($("#status"+str[i]).val()!=1){
                    msg="非待审核状态不能被审核!";
                    b=true;
                    };
                }
                if(type==1){
                    if($("#status"+str[i]).val()!=0){
                    msg="非无效状态不能被恢复!";
                    b=true;
                    };
                }
                if(type==0){
                    if($("#status"+str[i]).val()==0){
                    msg="无效状态不能被删除!";
                    b=true;
                    };
                }
            });

            if(b){
            alert(msg);
            return;
            }

            if(str.length == 0){
                alert("至少选择一条记录");
                return;
            }
            if(confirm("确定执行此操作?"))
            $.post("${pageContext.request.contextPath}/admin/ppstandard/statusbatch"
                    , {
                ids:str.join(","),
                _json : -1,
                type : type
            }, function(data) {
                eval(data);
                if (data.success) {
                    alert("操作成功")
                    location.reload();
                }
                if (data.failed) {
                    alert(data.failed);
                }

            }, "json");
            else{
                return;
            }
        }
       //全选和取消全选
        var checked = false;
        function refreshTree(industryId){

            $("#btcb").click(function(){
                if(!checked){
                    $("[name='checkbox']").attr("checked",'true');//全选
                    checked = true;
                }else{
                    $("[name='checkbox']").removeAttr("checked");//取消全选
                    checked=false;
                }

                });
        }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表