File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to retain drop-down list value after submit? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to retain drop-down list value after submit?" Watch "How to retain drop-down list value after submit?" New topic
Author

How to retain drop-down list value after submit?

smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
I have a <select> tag with 2 options.
When 1st option is selected, 2 text fields namely FirstName and LastName have to be displayed.
When 2nd option is selected, 1 text field asking for GroupName has to be displayed.
Problem: when 2nd option is selected and user enters the groupname and clicks "submit", the option automatically changes to "1st option" and fields (Firstname and Lastname) are displayed. I want to retain the 2nd option (and its respective field) after clicking submit. How do I achieve it?

I have tried to put only necessary part of the code only. dont mind the tag formations.

code: test.html

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Adding the "selected" attribute to an option cause it to show as selected.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
wood burning stoves
 
subject: How to retain drop-down list value after submit?