Pick value in dropdown combo on WebBrowser page

B

BobRoyAce

How do I programmatically set the value picked in a drop down? So,
let's say that I have a dropdown that has three possible values:
"Car", "Truck", and "Bicycle". What code would I use to set the picked
value to, for example, "Car"?
 
G

GArlington

How do I programmatically set the value picked in a drop down? So,
let's say that I have a dropdown that has three possible values:
"Car", "Truck", and "Bicycle". What code would I use to set the picked
value to, for example, "Car"?

selectbox.value = corresponding_value_for_your_selection (as in
<option value="...">Car</option>)
 
T

Thomas 'PointedEars' Lahn

How do I programmatically set the value picked in a drop down? So,
let's say that I have a dropdown that has three possible values:
"Car", "Truck", and "Bicycle". What code would I use to set the picked
value to, for example, "Car"?

Since

selectRef.value = "Car";

is not going to work everywhere:

var i = 0;
selectRef.selectedIndex = i;

How to obtain `i' for the general case is left as an exercise to the
reader.

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-94282980


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top