Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to auto select the value in drop down list

 
gaurav chhabra
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir
i have ondrop down list and i want to retrieve some value from database and then want that value to be selected in that drop down list .

plz tell me that how to do that because it is urgent...

thank you
gaurav
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add the selected atttribute in the option tag when you are creating the drop down on the server

or if you are not creating it dynamically you can do it with JavaScript if you know where it is on the list.

document.FormName.elementName.selectedIndex = 2;

If you do not know where it is, you need to loop through the options until it matches then select it.

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