zoukankan      html  css  js  c++  java
  • 只有一个radio的单选框如何在选中后取消选中

    <input type="radio" id="all" value="1" name="executeRadio"  <s:if test="bankApointDateDayCondtion!=null">checked="checked"</s:if> >

    var redioCount = 0;
        $(document).ready(function (){

       if($("#all").attr("checked")=="checked") redioCount=1;
            $("input[type='radio']").click(function(){
               if(redioCount == 1){
                    $(this).removeAttr("checked");
                    redioCount=0;
               }else {
                    $(this).attr("checked","checked");
                    redioCount=1;
                }
            });

    })

    实例:

    <input type="radio" id="all" value="1" name="executeRadio"  <s:if test="bankApointDateDayCondtion!=null">checked="checked"</s:if> > 每周指定日执行

    <table border="0" width="100%" align="center" cellpadding="2"
                                            cellspacing="5" >
                                        <tr>                
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isSun==1?"checked":""} value="1"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isMon==1?"checked":""} value="2"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isTue==1?"checked":""} value="3"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isWed==1?"checked":""} value="4"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isThur==1?"checked":""} value="5"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isFri==1?"checked":""} value="6"></td>
                                            <td><input type="checkbox" name="bankApointDateDayCondtions" <s:if test="withdrawConfig.bankApointDateDayCondtion==null">disabled="disabled"</s:if> ${withdrawConfig.isSat==1?"checked":""} value="7"></td>
                                            
                                        </tr>
                                        <tr>                
                                            <td>周日</td>
                                            <td>周一</td>
                                            <td>周二</td>
                                            <td>周三</td>
                                            <td>周四</td>
                                            <td>周五</td>
                                            <td>周六</td>
                                        </tr>
                                    </table>

      var redioCount = 0;
        $(document).ready(function (){

       if($("#all").attr("checked")=="checked") redioCount=1;
            $("input[type='radio']").click(function(){
               if(redioCount == 1){
                    $(this).removeAttr("checked");
                    
                    $("input[name='bankApointDateDayCondtions']").each(function(){
                        $(this).attr("disabled","disabled");
                        $(this).removeAttr("checked");
                    });
                    redioCount=0;
               }else {
                    $(this).attr("checked","checked");
                    $("input[name='bankApointDateDayCondtions']").each(function(){
                        $(this).removeAttr("disabled");
                    });
                    redioCount=1;
                }
            });

    })

    function submitForm(){

      if($("#all").attr("checked")!=undefined ){//勾选
                var checkArry = document.getElementsByName("bankApointDateDayCondtions");
                var isChecked=false;
                for (var i = 0; i < checkArry.length; i++) {
                    if(checkArry[i].checked == true){
                        isChecked=true;
                    }
                }
                if(!isChecked){
                    alert("请选择指定执行的日期!");
                    return false;
                }
            }

    }

  • 相关阅读:
    Struts2多文件上传
    Struts2单文件上传
    java验证码
    spring-day01
    Spring MVC篇一、搭建Spring MVC框架
    连接oracle数据库
    spring 核心技术
    Spring的特点
    spring连接数据库
    oracle学习第六天
  • 原文地址:https://www.cnblogs.com/shz365/p/6145927.html
Copyright © 2011-2022 走看看