
?Selecting/Indexing Options elements by Name value
Hi,
If you set the "id" of the option to the same as the value...and your values
are unique, you can use the select.options collection. For example:
--------------------
<html>
<body>
<select id="selMe">
<option id="Val 1">Val 1</option>
<option id="Val 2">Val 2</option>
<option id="Val 3">Val 3</option>
<option id="Val 4">Val 4</option>
<option id="Val 5">Val 5</option>
<option id="Val 6">Val 6</option>
<option id="Val 7">Val 7</option>
</select>
<input type="button" value="Go to 'Val 6'"
onclick="selMe.options('Val 6').selected = true">
</body>
</html>
-----------------------
Quote:
> Is there a way of selecting an Options list in a Select element by the
text
> value instead of a numeric index value without having to do a compare
> against all option text values to get the relative numerical index value?
> Background: We have a Select element with a list of options. When we do
a
> query against a db table we get a value that corresponds to one of these
> selection options. Using this value we want to set/scroll the
corresponding
> option into view.