This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Javascript to Select an Item in a Select List

 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thsi causes an error. Please help with correct syntax.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run this code the alert will produce -1 eventhough projindex = 201

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic