• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How to retain drop-down list value after submit?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding the "selected" attribute to an option cause it to show as selected.
reply
    Bookmark Topic Watch Topic
  • New Topic