aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Dropdown select box - Setting the default display value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dropdown select box - Setting the default display value" Watch "Dropdown select box - Setting the default display value" New topic
Author

Dropdown select box - Setting the default display value

Liz Costelloe
Greenhorn

Joined: Nov 01, 2003
Posts: 17
Hi,

I'm trying to provide a page where users can edit existing records from a database. I'm using a series of input & droplists to do this. Ideally I would like the page to open with each droplist displaying the values stored in the database & not just the first value in the list. Does anyone know the code that will do this for me??

Thanks
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
add the text 'selected="selected"' (without the single quotes) to the <option ... > elements you want to show up as defaults.

For example
[code]
<select id="s1">
<option value="1">One</option>
<option value="2" selected="selected">Two</option>
<option value="3">Three</option>
</select>
[code]

Will show the second option by default. If more than one has the parameter "selected" set, the last such will be defaulted.
[ June 04, 2004: Message edited by: Jeroen Wenting ]

42
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

Moving to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dropdown select box - Setting the default display value