Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes how to auto select the value in drop down list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to auto select the value in drop down list" Watch "how to auto select the value in drop down list" New topic
Author

how to auto select the value in drop down list

gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
 
wood burning stoves
 
subject: how to auto select the value in drop down list