A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
Show last value in the html:select
Joined: Oct 09, 2003
Apr 20, 2006 09:02:00
I have a query.
I have to show last value of the html:select as default vale in the form.How can i show that plz help me..
In the collection ,imagine there are three values, Orange,Grape,Apple
I have to show the last one Apple in the combo box.
Thanks in advance.
God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Joined: Feb 15, 2005
Apr 20, 2006 09:16:00
If you're using <html
ptions> along with your <html:select>, the option selected will be the option that matches the value in the ActionForm property you specified in the <html:select tag. So, if you specified:
<html:select property="fruit" >
ptions name="myForm" property="fruits" />
At some point prior to the page being displayed (either in your Action class, or in the reset() method of your ActionForm bean) add the following statment:
If it has to be the last option, no matter what it is, then code the following:
This assumes that getFruits() returns a List.
[ April 20, 2006: Message edited by: Merrill Higginson ]
I agree. Here's the link:
subject: Show last value in the html:select
passing parameter from servlet to jsp
Struts more html:select
Populating select lists on a form
Code optimization for html:option tag
Ajax and jsp as response
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015