Does anyone know wherer there is a javascript method to set the selection of a combo list?
![]() |
Does anyone know wherer there is a javascript method to set the selection of a combo list?
Something like this maybe...
Imagine you had the following list:
You could then have a function like below:Code:<select name="testselect">
<option value="first">first option</option>
<option value="second">second option</option>
<option value="third">third option</option>
</select>
So if you called selectMe with a value of "second", it would select the second option in the dropdown.Code:function selectMe(val) {
for (var i=0; i<document.all.testselect.length; i++) {
if (document.all.testselect.options[i].value == val) {
document.all.testselect.options[i].selected = true;
}
}
}
Is that what you meant?
Yes, absolultely right, My problem was solved so well. Thank you very much
All times are GMT -7. The time now is 07:08 AM. |