| Author |
Show last value in the html:select
|
MInu
Ranch Hand
Joined: Oct 09, 2003
Posts: 517
|
|
Hi all, 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
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
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" > <html ptions name="myForm" property="fruits" /> </html:select> 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: myForm.setFruit("Apple"); If it has to be the last option, no matter what it is, then code the following: myForm.setFruit(myForm.getFruits().get(myForm.getFruits().size()-1); This assumes that getFruits() returns a List. [ April 20, 2006: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
 |
|
|
subject: Show last value in the html:select
|
|
|