By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,035 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,035 IT Pros & Developers. It's quick & easy.

Get text value from <select>

P: n/a
How do I get the textual content of an <option> element within a <select>
control? e.g. <select name='tc'><option value='0'>All</option><option
value='1'>Some</option></select>

Get the value "Some" returned from the <select> using Javascript?
Sep 9 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Davey wrote:
How do I get the textual content of an <option> element within a <select>
control? e.g. <select name='tc'><option value='0'>All</option><option
value='1'>Some</option></select>


The DOM for HTML <option> elements is documented here:
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-70901257>
so
option.text
is what you are looking for once you have an option element object.
If you have the select e.g.
var select = document.forms.formName.elements.tc;
then you can e.g. access
select.options[1].text
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.