|
Posted by JDS on July 27, 2005, 2:10 pm
Please log in for more thread options
On Wed, 27 Jul 2005 09:35:11 -0700, passion_to_be_free wrote:
> I have have some values stored in javascript variables. I have a
> <select> dropdown list whose options correspond to these values. I want
> to be able to select an item on the dropdown list based on the value of
> the javascript variable.
>
> Let's say this is my list and my variable:
>
> <select id='popup'>
> <option value="default">--Please Choose a saying--</option>
> <option value="hello">Hello</option>
> <option value="goodbye">Goodbye</option>
> </select>
>
> var input = "hello";
>
> Is there a way to select the 2nd option using using that variable
> value? Something like:
>
> var popup = document.getElementById("popup");
> popup.selectedItem = input;
I'm a smidge confused by your description.
Do you want to have the item in the dropdown list become selected based on
the value of another JavaScript variable? So that, when this other
variable, "input", becomes equal to, say, "hello", the second item in
"popup" becomes selected?
Or do you just want to get the value of the second item in the "popup"
drop-down list?
The two tasks are similar but obviously not exactly the same.
--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
|