How can you get the selected value from drop down list using JavaScript? I have tried the following but it does not work.
var sel = document.getElementById(\
It is working fine with me.
I have the following HTML:
And the following JavaScript:
function GetSelectedItem(el)
{
var e = document.getElementById(el);
var strSel = "The Value is: " + e.options[e.selectedIndex].value + " and text is: " + e.options[e.selectedIndex].text;
alert(strSel);
}
See that you are using the right id. In case you are using it with ASP.NET, the id changes when rendered.