Kosko
07-15-2009, 03:19 PM
So I've got some simple javascript functions to set dropdown selections based on index. But I've also have a field that needs to be selected based on its text (possibly value, but text would be better).
The current code is really just based around this line:
document.getElementById("Option3")[myOption1].selected = true;
and what I'm looking for is:
document.getElementById("Option3").getIndexByText("TheSelectorText").selected = true;
Is there a built in function for this? Has anyone implemented it? I searched google and there didn't seem to be any standout answers.
Thanks!
The current code is really just based around this line:
document.getElementById("Option3")[myOption1].selected = true;
and what I'm looking for is:
document.getElementById("Option3").getIndexByText("TheSelectorText").selected = true;
Is there a built in function for this? Has anyone implemented it? I searched google and there didn't seem to be any standout answers.
Thanks!