1
<select name="recordLimit" id="recordLimit">
    <option value="10">Last 10</option>
    <option value="50">Last 50</option>
    <option value="100">Last 100</option>
    <option value="500">Last 500</option>
    <option value="0">All</option>
</select>

I have a search page with some drop downs and the user can choose and search data for it. I have a record limit drop down that limits no of records returned on search. Say if I select last 50 records in the drop down and it gives me the last 50 records in the results page. but I want to remember the value selected in the jsp page(ie.. display last selection when the results are rendered)

Shota
  • 6,910
  • 9
  • 37
  • 67
user3362080
  • 301
  • 1
  • 4
  • 10
  • you'll need to return the information to your jsp when it's built to know which one was selected. then simply put "selected" on the option last chosen. http://www.w3schools.com/tags/att_option_selected.asp – Taplar May 05 '15 at 19:13
  • should I do that with a jquery? – user3362080 May 05 '15 at 19:17
  • No, this would be in your jsp logic. – Taplar May 05 '15 at 19:18
  • Thanks. How do I add that selected attribute selected="selected" for the value that user selects( which is accessible via "${actionBean.recordLimit}") – user3362080 May 05 '15 at 19:27
  • Been a while since I did jsp logic, however you should be able to use c:if when you build your select html. http://stackoverflow.com/questions/5935892/if-else-within-jsp-or-jstl You can build your if to check if the last used value equals the value of the option your fixing to build and if so to add the selected tag to it. otherwise, leave it off. Or if your using to build it, it may have an optional parameter that you can provide which option to start with as selected. – Taplar May 05 '15 at 19:33

1 Answers1

0

If I understood: you can do this:

String option = request.getParameterName("recordLimit") // get option selected
session.setAttrubute("recordLimit", option) // display last option selected from session
Raphael Milani
  • 151
  • 2
  • 14