CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Home > CodeDigest >  
Technologies
 


Get Selected RadioButtonList Value using JavaScript in ASP.Net
Submitted By Satheesh Babu B
On 7/14/2009 9:05:27 AM
Tags: ASP.Net,CodeDigest,JavaScript  

Get Selected RadioButtonList Value using JavaScript in ASP.Net

At times, there will be need to get the selected or checked RadioButtonList value from javascript to do some validations on client side.

The following javascript will help us to do that.  

<script language="javascript" type="text/javascript">      

        function GetRDBValue()

        {

            var radio = document.getElementsByName('rdbGender');

            for (var i = 0; i < radio.length; i++)

            {

                if (radio[i].checked)

                {

                    alert(radio[i].value);

                 }

            }

        }

</script>

 

<asp:RadioButtonList ID="rdbGender" runat="server">

            <asp:ListItem Text="Male" Value="1"></asp:ListItem>

            <asp:ListItem Text="Female" Value="2"></asp:ListItem>           

</asp:RadioButtonList>

Recent Codes
  • View All Codes..