Click here to Skip to main content
15,886,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a radio button and a radio button list used for making chart in asp.net...
These two buttons represent two different values and I cannot combine them...
I want to un-check the radio button if any one of the buttons in the radio button-list is checked and un-check the radio button-list if the radio button is clicked...

ASP.NET
<asp:RadioButton ID="rbtnZone" runat="server" GroupName="rb" Text="Zone Wise" />

<asp:RadioButtonList ID="rbtnStore" runat="server" CellPadding="3" GroupName="rb" RepeatColumns="4" RepeatDirection="Horizontal">
</asp:RadioButtonList>
Posted
Updated 16-Dec-15 0:02am
v2
Comments
xszaboj 16-Dec-15 6:05am    
could you please post the html? I will create example in codepen.
SajinAboo 16-Dec-15 6:12am    
Hi,

I am using this two asp radio buttons for drawing charts.
Both the buttons have click function that is used to form charts. The chart works fine, but on selecting one value from the radio button list the other radio button remains checked...

Here is one example using jquery :

ASP.NET
<asp:RadioButton ID="rbtnZone" runat="server" GroupName="rb" Text="Zone Wise" />
        <br />
        <asp:RadioButtonList ID="rbtnStore" runat="server" CellPadding="3" GroupName="rb"
            RepeatColumns="4" RepeatDirection="Horizontal">
           
        </asp:RadioButtonList>


JavaScript
$(document).ready(function () {
           $('#rbtnZone').click(function () {
               $('#<%=rbtnStore.ClientID %> input:radio').each(function () {
                   $(this).prop('checked', false);
               });
           });

           $('#rbtnStore').change(function () {
               $('#rbtnZone').prop('checked', false);
           });

       });


hope it helps you.
 
Share this answer
 
v3
Comments
SajinAboo 16-Dec-15 6:59am    
Hi,

Thanks for the codes... It is working, but only when I click on the Zone radio button, The radio button list gets cleared... But on clicking the Radio Button list the checked is showing in the Zone Radio button...
Raje_ 16-Dec-15 7:32am    
It's working for me. Can you debug your code in firebug and see what is happening there?
SajinAboo 16-Dec-15 7:37am    
Thanks for the help... It worked... The second function change() has some modification... $('#<%=rbtnZone.ClientID %>').prop('checked', false); instead of $('#rbtnZone').prop('checked', false);
Raje_ 16-Dec-15 7:40am    
Cool..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900