• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need to choose a value from list item in jsp

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
I need to choose the value of a list item in jsp. There are many employees in various departments and i need to choose that employees in department wise.


Example. I have two list items in jsp
1. Select dept_no,dept_name from departments
2. SElect emp_name from employees, departments where emp_dept_no=curr_dept_no and curr_dept_no = dept_no

These two are the list items. When i choose the department from the first list item i need to display the employees in that particular department in the second list.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to assume that by "list item" you mean a select/option control. So if I understand correctly, the contents of the second select control are dependent on the choice made in the first select control.

So, populate the first select control on page load (the $(document).ready(function())). For the second one, use jQuery to bind the "onChange" event to an Ajax call that returns the list of employees.

This probably needs to be moved to our JavaScript forum, but before I do that, let me make sure I understand your requirements and that you intend to use JavaScript to accomplish this.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
Britto Moris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Mr. Kevin Robbins. And what you understand is exactly correct. Both list item values are obtained using SQL queries.
Will you please help me to solve this issue.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's your turn.
What have you tried?
What have you researched? There were several keywords that Kevin mentioned.

First steps:
Populate a select element with the list of departments.
Write a service/servlet that takes a department id, and returns a list of employees in that department - in a format that Javascript can understand.
Wire up the onclick event to on the element in the first step to make an ajax call to the service in the second step, and populate the second select box with the results.

If you get stuck, we can probably provide some pointers and help, but you have to do this yourself.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Stefan has indicated, we are a learning site, not a code mill. We expect you to ShowSomeEffort. One of the basic skills needed for programming is the ability to take a large problem and break it down into smaller, manageable problems. Stefan has done that for you with three good starting points. Take the first one and give it a shot. Post your results here and tell us where you are having trouble and we'll help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic