SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Setting SELECT option value
Threaded View
-
Jul 19, 2007, 15:29 #1
- Join Date
- Dec 2003
- Location
- Ireland
- Posts
- 116
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Setting SELECT option value
Hi All,
In JS can you set the value of a SELECT dropdown box by text value, not index value?
The following will set the SELECT box by the index value, selecting the second value in the dropdown box
var varyear = 1
document.myform.year.options[varyear].selected = true;
however i want to set it like this...
var varyear = 2006
document.myform.year.options[varyear].selected = true;
...to set the SELECTED value to 2006...which doesn't work
Thanks for any help
Melt
Bookmarks