473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Get text value from <select>

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
1 19541


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Raghuram Banda | last post by:
Hi All, Can any one help me, how to get the selected value from <Select> tag using DOM I tried with document.getElementById("selectTagId").getAttribute("value") it's working fine with IE but...
1
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
3
by: veg_all | last post by:
Say I have: <select> <option value='a' > First <option value='b' > Second <option value='c' > Third </select> Is there a way I can access the values First, Second and Third from an array ?...
4
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
2
by: msg2ajay | last post by:
hi all, I have a problem with <html:select> i am getting a value from the database but it is not setting to my <select value>. Can any bady tellme what is the problem. My code is given...
1
by: Eric | last post by:
Hello, I'm trying (without any success) to get the value of a disabled select control. From reviewing: http://www.w3.org/TR/html401/interact/forms.html#adef-disabled It doesn't sound like...
14
mikek12004
by: mikek12004 | last post by:
In a form I have 5 elements (e.g. pictures) and I wish for the user to be able to set the order of appearance. For this I have for each picture a select box (names select1 to select5) with "please...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.