|
 |
javascript thread: Read <option> text </option>
Message #1 by plscribner@w... on Wed, 22 May 2002 00:17:57
|
|
Hi... you can try some function like:
<script>
function copy()
{
var
foo=document.form_name.select_name.options[document.form_name.select_name.se
lectedIndex].text;
document.form_name.textbox_name.value=foo;
}
</script>
And then just call the function copy() on your onChange....:
<select name="mySelect" size="1" onChange="copy()">
Cumprimentos
Mário Ramos (3812)
ICQ# 88933965
----- Original Message -----
From: <plscribner@w...>
To: "javascript" <javascript@p...>
Sent: Wednesday, May 22, 2002 12:17 AM
Subject: [javascript] Read <option> text </option>
> Hi All,
>
> I have a <select> block with several <options>. The value inside each
> option is the primary key to a database record. The english
> representations from which users make their selections are, of course,
> text. For example:
>
> <select name="mySelect" size="1">
> <option value=234>1947 Chevrolet</option>
> <option value=63>1977 Cadillac</option>
> </select>
>
> When the user selects one of the options I need to use onChange to copy
> the text between the <option></option> tags for their selection to a text
> box. But I can't find the right property to do so. I can 'value'
> and 'selectedIndex' but not the actual text.
>
> Can anybody give me a hand with this?
>
> Thanks so much in advance.
>
> Peter
>
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>
|
|
 |