首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

jquery形式操作radionbutton

2013-03-21 
jquery方式操作radionbutton想实现选择1年,月结 60天/60天 那个radiobutton不可用,选择 1 年 ,月结

jquery方式操作radionbutton
想实现选择<=1年,月结 >= 60天/<60天 那个radiobutton不可用,选择> 1 年 ,月结 < 60 天 和月结 >= 60天 这两个radiobutton不可用。
以下是我实现的办法 在火狐下面没有问题 但是在ie上只要选择<=1年或者> 1 年的radiobutton下面三个全部不可用,再怎么点击都没有反应了,不知道什么原因 求大师帮忙。
jquery形式操作radionbutton


contractApp.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="CPH_Head" runat="Server">
<script type="text/javascript">
        function IsEnable() {
            $("#ctl00_WFContent2_rdPay1").attr("disabled", true);
            $("#ctl00_WFContent2_rdPay2").attr("disabled", true);
            $("#ctl00_WFContent2_rdPay3").attr("disabled", false);
            if ($("#ctl00_WFContent2_rdPay3")[0].checked) {
                $("#ctl00_WFContent2_rdPay3").removeAttr("checked");
            }
        }
        function IsDisEnable() {
            $("#ctl00_WFContent2_rdPay1").attr("disabled", false);
            $("#ctl00_WFContent2_rdPay2").attr("disabled", false);
            $("#ctl00_WFContent2_rdPay3").attr("disabled", true);
            if ($("#ctl00_WFContent2_rdPay1")[0].checked) {
                $("#ctl00_WFContent2_rdPay1").removeAttr("checked");
            }
            else if ($("#ctl00_WFContent2_rdPay2")[0].checked) {
                $("#ctl00_WFContent2_rdPay2").removeAttr("checked");
            }
        }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="WFContent2" runat="Server">
<asp:RadioButton ID="rdDate1" runat="server" GroupName="GroupCAppDate" Enabled="true" Text="<= 1年" />
<asp:RadioButton ID="rdDate2" runat="server" GroupName="GroupCAppDate" Enabled="true" Text="> 1 年" />


<asp:RadioButton ID="rdPay1" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 < 60 天" />
<asp:RadioButton ID="rdPay2" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天" />
<asp:RadioButton ID="rdPay3" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天/<60天" />
</asp:Content>

contractApp.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
        rdDate1.Attributes.Add("onclick", "IsEnable()");
        rdDate2.Attributes.Add("onclick", "IsDisEnable()");


}


jquery radiobutton
[解决办法]
http://bbs.csdn.net/topics/390362473
[解决办法]
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("input[id$=rdDate1]").bind('click', function () {
                $("input[id*=rdPay]").removeAttr("checked").attr('disabled', false);
                $("input[id$=rdPay3]").attr('disabled', true);                
            })
            $("input[id$=rdDate2]").bind('click', function () {                
                $("input[id*=rdPay]").removeAttr("checked").attr('disabled', false);
                $("input[id$=rdPay1]").attr('disabled', true);
                $("input[id$=rdPay2]").attr('disabled', true);                
            })
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    <asp:RadioButton ID="rdDate1" runat="server" GroupName="GroupCAppDate" Enabled="true"
                        Text="<= 1年" />
                    <asp:RadioButton ID="rdDate2" runat="server" GroupName="GroupCAppDate" Enabled="true"
                        Text="> 1 年" />
                </td>
            </tr>
            <tr>
                <td>


                    <asp:RadioButton ID="rdPay1" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 < 60 天" />
                    <asp:RadioButton ID="rdPay2" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天" />
                    <asp:RadioButton ID="rdPay3" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天/<60天" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>


[解决办法]
 <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#<%=rdDate1.ClientID %>").bind('click',IsEnable);
            $("#<%=rdDate2.ClientID %>").bind('click',IsDisEnable);
        });

         function aaa() {
             alert("sss");
         } 


        function IsEnable() {
            $("#<%=rdPay1.ClientID %>").attr("disabled", true);
            $("#<%=rdPay2.ClientID %>").attr("disabled", true);
            $("#<%=rdPay3.ClientID %>").attr("disabled", false);
            if ($("#<%=rdPay3.ClientID %>")[0].checked) {
                $("#<%=rdPay3.ClientID %>").removeAttr("checked");
            }
        }
        function IsDisEnable() {
            $("#<%=rdPay1.ClientID %>").attr("disabled", false);
            $("#<%=rdPay2.ClientID %>").attr("disabled", false);
            $("#<%=rdPay3.ClientID %>").attr("disabled", true);
            if ($("#<%=rdPay1.ClientID %>")[0].checked) {
                $("#<%=rdPay1.ClientID %>").removeAttr("checked");
            }


            else if ($("#<%=rdPay2.ClientID %>")[0].checked) {
                $("#<%=rdPay2.ClientID %>").removeAttr("checked");
            }
        } 
    </script>
    <asp:RadioButton ID="rdDate1" runat="server" GroupName="GroupCAppDate" Enabled="true"
        Text="<= 1年" />
    <asp:RadioButton ID="rdDate2" runat="server" GroupName="GroupCAppDate" Enabled="true"
        Text="> 1 年" />
    <asp:RadioButton ID="rdPay1" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 < 60 天" />
    <asp:RadioButton ID="rdPay2" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天" />
    <asp:RadioButton ID="rdPay3" runat="server" GroupName="CAppPay" Enabled="true" Text="月结 >= 60天/<60天" />

热点排行