<html>
<head >
<title></title>
<script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btn1").click(function () {
var value=$("#ddl1 option:selected").val();
var txt = $("#ddl1 option:selected").text();
$("#ddl1
option[value=Opt2]").prop("disabled", true);
if(value!="Select")
{
alert("Select
option:" + "\n" + "value:" +value +"\n"+"text:" + txt);
}
else
{
alert("Please select
any one");
}
});
});
</script>
</head>
<body>
<form id="form2" runat="server">
<div>
<b>Select Option:</b>
<asp:DropDownList ID="ddl1" runat="server">
<asp:ListItem Text="Select" Value="Select" />
<asp:ListItem Text="Option1" Value="Opt1" />
<asp:ListItem Text="Option2" Value="Opt2" />
<asp:ListItem Text="Option3" Value="opt3" />
</asp:DropDownList>
<input type="button" id="btn1" value="Submit" />
</div>
</form>
</body>
</html>
Output:
No comments:
Post a Comment