Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Selecting value in select tag

 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JS, How do I show selected value in <select> tag, if I have value which is to be selected but don't have index.
One way is I have to loop thru options of select tag, check their values.
But Is there any other way to do this?

Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going to have to loop through the options to find it.

Eric
 
Ryan Asleson
Author
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the select tag is a single select tag, can't you just access the select tag's value? I think this will report the value of whatever option is selected.... I think.
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.
But I am not satisfied with these answers.
If I don't want to loop thru options of select, then is there any other way.

Hi Ryan,
I didn't get what you are trying to tell.
My question was, if I have which option value to be selected at time of page load(not index and don't want to access the value but wants to set the value to be selected), then what?
[ September 25, 2006: Message edited by: Deepa More ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He is saying set the value directly and see if it works.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic