Getting Dropdown selected Value and Selected Text using JQuery
Some we require to get the selected value(id) with their corresponding value. So we can get by this way :-
This is simplest way to get :-
<script type="text/javascript"
src="jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
<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>
Call the subsequent parameter where you want to use :-
<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>
Any Query...!!
The given information in this article is very informative
ReplyDeletesharepoint online training
It helped me a lot. Thanks for sharing useful tutorial.
ReplyDelete