| Author |
Using Javascript to Select an Item in a Select List
|
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1261
|
|
Thsi causes an error. Please help with correct syntax.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
If you want to select an item, you need to just set the selected index The code you showed in your above post is how you would get the option reference that is selected so you could get the text or value or set the option with new Option. Eric
|
 |
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1261
|
|
When I run this code the alert will produce -1 eventhough projindex = 201
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
That the index value or the value of the element, I am guessing the value. Therefore you will need to reference the value. now if that does not work, you will have to look through the options and match the value and than select it. Eric
|
 |
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1261
|
|
You were exactly right. I was capturing the option value instead of the item index so on refresh button click there was no index that could be found. Thanks for the help.
|
 |
 |
|
|
subject: Using Javascript to Select an Item in a Select List
|
|
|