Click here to Skip to main content
15,915,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a drop down lists in my page i would like get the list in javascipt by using its tagname 'select'. Now my question is how to get the dropdown list selected item in javascript.

Thanks in Advance
Seshu
Posted

1 solution

something like this:

C#
function GetSelectedValue(selectItem)
{
    var index = document.getElementById(selectItem).selectedIndex;

    alert("value =" + document.getElementById(selectItem).value);
    alert("text =" + document.getElementById(selectItem).options[index].text);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900