This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain drop-down list value after submit?

 
smee bond
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding the "selected" attribute to an option cause it to show as selected.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic