得到复选框的值

复选框按钮:

              <input type="checkbox" id="check_all"  name="check_all"

                                         <c:if test="${on eq 'on'}">checked="checked"</c:if>        />全选

              <input type="checkbox" name="deptname_checkbox" value="${...}"/>

JS:

               //全选及反选
           $("#check_all").click(function(){
                             var flag = this.checked;
                             $("input[name=deptname_checkbox]").each(function(){
                                                this.checked = !flag?false:true;         
                             });
            });

                      

               //选择复选框后若有操作时:(如查询)

            <input type="submit" id="search_btn" value="查询" οnclick="search();"/>

                function search(){
                              var dept_Ids = "";
                              $("input[name='deptname_checkbox']").each(function(){
                                        if(this.checked==true){
                                                     dept_Ids+=this.value+",";
                                        }
                                });
                                if(dept_Ids.length>0){
                                                dept_Ids=dept_Ids.substring(0,dept_Ids.length-1);
                                }
                                document.getElementById('form1').action='..... +encodeURI(......); //中文传值乱码转换
                                document.getElementById('form1').submit();
             }       

 

             //复选框回值
             $("input[name=deptname_checkbox]").each(function(){
                             var deps = "${dept_Ids}";
                             if(deps.indexOf(this.value)!=-1)    this.checked = true;
           });
                                           

java后台:

             String on = getRequest().getParameter("check_all");
                getRequest().setAttribute("on", on);

                

                String dept_Ids = getRequest().getParameter("dept_Ids");

             getRequest().setAttribute("dept_Ids", dept_Ids);

                

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值