93
rated 0 times
[
95]
[
2]
/ answers: 1 / hits: 145707
/ 14 Years ago, thu, october 21, 2010, 12:00:00
Say I have a dropdown list like this:
<select id="MyDropDown">
<option value="0">Google</option>
<option value="1">Bing</option>
<option value="2">Yahoo</option>
</select>
and I want to set the selected value based on the option text, not the value with javascript. How can I go about doing this? For example, with c# I can do something like the example below and the the option with "Google" would be selected.
ListItem mt = MyDropDown.Items.FindByText("Google");
if (mt != null)
{
mt.Selected = true;
}
More From » javascript