Dropdownlist text value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can't seem to find the syntax to retrieve the text portion of a dropdownlist.

I can find the value:
document.getElementById("Age").value;

and the selected index:
document.getElementById("Age").selecteIndex;

but the text property gives an 'undefined' result. Any ideas?

Thanks,
Denise
 
Denise,

All you have to do is:

var oOption = document.getElementById("Age");
var strText = oOption.options[oOption.selectedIndex].text;

strText should contain the value you are looking for.

Dave
 
Back
Top