• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dropdown select box - Setting the default display value

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the HTML/Javascript forum.
 
reply
    Bookmark Topic Watch Topic
  • New Topic