• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dropdown select box - Setting the default display value

 
Liz Costelloe
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the HTML/Javascript forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic