Manage two radioButton

1 posts, 0 answers
  1. Colince
    Colince avatar
    11 posts
    Member since:
    Apr 2013

    Posted 16 Sep 2013 Link to this post

    I have 2 radiobuttons on my grid that are mutually exclussive and i also have on checkbox. This 2 radiobuttons are enabled/disabled when i click on the checkbox using javascript function. I have in the code behind the method manageSelected which are call while clicking on the button save. Initially the 2 radiobuttons are enabled.  Without the javascript function all thing work fine(i can check one of the radiobutton and save his value). My issue is that when i apply the javascript it work only in one way(I can change my object property value from value of radiobutton1 to the one of radiobutton2 and not mutual).

    My file.aspx
                            <asp:CheckBox ID="rbDiscountGoodCalcTypeSet" runat="server" BackColor="red" onchange="onChangeDiscountGoodCalcType()"/>
                            <asp:Label ID="lbDiscountGoodCalcType" runat="server" Text="<%$ Resources: Common, DiscountGoodCalcType %>"></asp:Label>
                        <td colspan="3">                      
                            <asp:RadioButton ID="rbDiscountGoodCalcType1" GroupName="DiscountGoodCalcType" runat="server"
                                Text="<%$ Resources: Common, ByQuantity %>" Checked='<%# Eval("DiscountGoodCalcType").ToString() == "0" %>' Enabled="false"/>
                            <asp:RadioButton ID="rbDiscountGoodCalcType2" GroupName="DiscountGoodCalcType" runat="server"
                                Text="<%$ Resources: Common, ByValue %>" Checked='<%# Eval("DiscountGoodCalcType").ToString() == "1" %>' Enabled="false"/>

    My javascript function
    function onChangeDiscountGoodCalcType() {
                var sourceName =;
                var targetName1 = sourceName.substring(0, (sourceName.length - 3)) + "1";
                var targetName2 = sourceName.substring(0, (sourceName.length - 3)) + "2";
                var cmdObj = $("#" + sourceName)[0];
                var targetObj1 = $("#" + targetName1)[0];
                var targetObj2 = $("#" + targetName2)[0];
                targetObj1.disabled = !cmdObj.checked;
                targetObj2.disabled = !cmdObj.checked;

    My savebutton call this method for the control
    private void Manage4Line()
                if (rbDiscountGoodCalcTypeSet.Checked)
                    DiscountGoodCalcType = (rbDiscountGoodCalcType1.Checked) ? 0 : 1;

Back to Top