<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:
Post a Comment