Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, March 29, 2012

Getting Dropdown selected Value and Selected Text using JQuery

<html>
<head>
<title>Enter Value in DropDown</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
    $("#btnGetDropDownValue").click(function()
    {
        alert('DropDown Value '+$("#ddlSample").val());
        alert('DropDown Text '+$("#ddlSample").find('option').filter(':selected').text());
    });
});
</script>
</head>

<body>
<table cellpadding="0" cellspacing="0">
<tr><td>Enter Value in TextBox</td><td><select id="ddlSample"><option value="A">A1</option><option value="B">B1</option><option value="C">C1</option></select></td></tr>
<tr><td colspan="2" align="center"><input type="button" id="btnGetDropDownValue" value="Get DropDown Value" /></td></tr>
</table>
</body>

</html>

No comments:

Post a Comment