We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Sunday, June 28, 2015

Radio Button List Example of jQuery

<head runat="server">
    <title></title>
    <script src ="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btn1").click(function () {
                if ($("#rdbList1 input:radio").is(":checked")) {
                    var chkrdb = $("#rdbList1 input:radio:checked");
                    var value = chkrdb.val();
                    var txt = $("label[for=" + chkrdb.prop("id") + "]").text();
                    alert("select option:\n"+ "Text:" + txt + "\n" + "value:" + value);
                }
                else {
                    alert("Please select any option");
                }
            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <b>Select Option:</b>
        <br />
        <asp:RadioButtonList ID="rdbList1" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Text="Option1" Value="Opt1" />
            <asp:ListItem Text="Option2" Value="Opt2" />
            <asp:ListItem Text="Option3" Value="Opt3" />
        </asp:RadioButtonList>
        <input type="button" id="btn1" value="Submit" />  

    </div>
    </form>
</body>
</html> 



OUTPUT:


No comments: