Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retain a selected value in a drop down.

 
Ash Acharya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a jsp wherein I have a select box, which gets populated from the database on form load. How do I get the selected value in the drop down when i visit the same page again?what I exactly mean is that i want to retain the previously selected value in the select box the next time i revisit the same page. I'm able to populate the other text fields on the form with the values they originally had, when i revisit the page. How can I achieve this?
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make sure that the name attribute in select tag matches the getter for the selected value.
If that is not possible for some reason, you should be able to set the selected option by setting it explicitly in the value attribute.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic