Dropdownlist text value

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
 
D

dph

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top