• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

selected attribute not working for dynamic dropdown list for a field to remain selected after submit

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JSP Page which accepts 4 fields. First field is populated by querying database as "Select Distinct field1 from db.table". After the user selects first field, onchange event causes field2 to be populated by querying the browser as "Select Distinct field2 from db.table where field1='"+value+"' ".

Same happens with 3rd and 4th fields. Now, when user submits the form, all fields get reset. I want the JSP page to show user selected values in all 4 fields.

If list in each dropdown is static (not dependant on other fields), then it works by using selected attribute. But this dependancy of each field on previous one is making it difficult.

Below code shows the user selected value after form submission for field1:


But for subsequent fields, onChange() event doesn't work, because we are not changing anything in field1.

I tried onLoad() to execute Javascript functions, but that doesn't seem to work.

How can we solve this???
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic