This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using SELECTED in an html:option tag

 
Andy Deighton
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know I can achieve the following:
<html ption value="Default" SELECTED>Default</html ption>
I know that SELECTED is not supported in Struts, so was wondering what the alternative approach is. I basically have a drop-down of countries and what to pre-select a particular one. Sounds simple? I wish!!
Regards,
Andy
UK
[ August 22, 2003: Message edited by: Andy Deighton ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "property" attribute of the <html:select> tag indicates a property of a bean or ActionForm which hold the "selected" value for your drop down.
Let's say your ActionForm has a property "book", and you have a JSP page where the user is supposed to select a book from a drop down.

If your ActionForm contains the value "Brave New World" for the property "book", then when your JSP renders, "Brave New World" will be SELECTED in your drop down.
HTH
 
Andy Deighton
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked excellently - many thanks. I just did lazy initialization on the appropriate accessor and bingo, the right default value is selected. Thanks again,
Andy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic