• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain the latest selected value of drop down box.

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

how to retain the latest selected value of drop down box.
In my jsp page i have drop down box's which showing the dates.

I want if i selected day 30 then on the submit button and when the form reloads it should retain its latest selected value .i.e 31.

Please help me how to do it.

Below is my jsp page code:



Actionc class







thanks
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

Just put at all your <s:select .../> box value tag. and that value equal to your <s:select .../> name tag.

Use


insted of

So, put just extra value tag at your select tag....


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Nishan: his select tags already *have* a "value" attribute set.

@Pankaj: I suspect the goal of your code is to display the current month/etc. on the first page view but the selected month/etc. on subsequent page views. Since you have a "value" attribute the select boxes will *always* show the current month/etc.

You can't have it both ways: if you use a "value" attribute that's the value that will be pre-selected. Another option would be to remove the "value" attribute and put the initial select value into the domain object (in your case the "employeetimesheetreport").

Two quick suggestions: use camel case for the domain object and its properties. "employeeTimeSheetReport.startMonth" is much easier to read than "employeetimesheetreport.startmonth". Also, spell "commonutil" correctly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic