Thursday 20 March 2014

radiobuttonlist checked in jquery

first need to read the Radio button and then read the checked value of radio button.
In code snippet showing the radiobutton value into alert message box, Event will fire whn click on hyperlink button


@Code Snippet for radiobuttonlist checked in jquery

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Check for radio button</title>
    <script type="text/javascript">
        function getvalue() {
            alert($('#<%=RadioButtonList1.ClientID %> input[type=radio]:checked').val());
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
            RepeatLayout="flow">
            <asp:ListItem Selected="True" Text="Yes" Value="0"></asp:ListItem>
            <asp:ListItem Text="No" Value="1"></asp:ListItem>
        </asp:RadioButtonList>
        <a href="#" id="button" onclick="getvalue()">click me</a>
    </div>
    </form>
</body>
</html>

No comments:

Post a Comment