This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retain drop-down list value after submit?
 
Similar Threads
what to do, if I get error `breaking on JScript rumtime error - object expected
Display a textbox after dropdown change
How convert into struts html select clause
Problem in form submitting.
URGENT Help needed on JavaScript.