• 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

Displaying value second drop down based on the value selected in the first drop down

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two drop down lists. Based on the value selected in the first drop down, the values in the second should pop up. And these values have to come from database. Can anyone help me how to do this plz.
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Latha
I'm no expert on this, but I'd think you would need to pass your request with the selection made in the first drop-down to a servlet, the servlet would in turn retrieve the appropriate data from the database based on that value, and then pass control to the JSP page to render this retrieved data in the 2nd drop-down.
The retrieved database data could be stored by the servlet in a Java Bean, and used as such (ie. jsp:useBean) in the JSP. Or the servlet could store the retrieved data as an Enumeration object of the database values, and the JSP could iterate through the Enumeration object to build the 2nd drop-down list. Presumably the Bean or Attribute objects would be in session scope as they are specific to a particular user.
Hope this helps
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In the OnChange event of the first combo box, call a javascript function.
In that Function just have the code to submit the page.U can submit the request to the same JSP page.U can retrieve the combo box value and call a beans method by passing the combobox value as a paremter to the method.
Use JSP usebean tag.
ie

where arrList would be an arrayList
Iterate the arrList and populte the second combo box..
Implement the database access logic in the bean.
Hope this helps
Cheers
Geeta
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic