Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use OPTION description 1

Status
Not open for further replies.

foxbox

Programmer
Sep 11, 2000
1,052
NL
<select name=field>
<option value=1>Apple
<option value=2>Banana
<option value=3>Ananas
</select>

in a script i can use document.form.field.value in order to get the selected value (eg 1). But how can i get the selected DESCRIPTION (eg Apple). . .

After selecting a value i want another field on screen to be filled with a default description; but i need the code/value too!
Of course i can change the value of each option into <code><description> (&quot;1Apple&quot; etc) but is there a more elegant way?


br
Gerard
(-:

| Do it!
|
V
 
use the text property, e.g.

document.form.field.options(document.form.field.selectedIndex).text

Note, I'd use a name other than &quot;field&quot; for your select box, like &quot;cboFruits&quot; or something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top