Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:54:06+00:00 2026-06-11T19:54:06+00:00

I have two tables in my Database. One is Department and other is Manager.

  • 0

I have two tables in my Database. One is Department and other is Manager. I created a drop down in JSP and it shows list of Departments from Database. I want to show list of Managers in another dropdown based on Department selected. how to achieve this?

Here, I am referring to cascading dropdowns. Thanks you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:54:07+00:00Added an answer on June 11, 2026 at 7:54 pm

    You have given no HTML or any script you have tried yourself as such the below should serve as a good template for you to get started.

    DEMO – Cascading dropdowns, show managers for selected department

    Assuming the following HTML

    <div>
        <div style="float: left;">
            Select Department
            <br />
            <select id="departments"></select>
        </div>
        <div style="float: left; margin-left: 10px;">
            Select Manager
            <br />
            <select id="managers"></select>
        </div>
    </div>
    

    ​
    When you have loaded the departments and managers from the database you can dynamically populate the selects with code similar to this:

    var $departments = $("#departments");
    var $managers = $("#managers");
    
    // This data would be loaded from the DB
    var departments = [
        {id: "1", value: "Department 1"},
        {id: "2", value: "Department 2"}
    ];
    
    // This data would be loaded from the DB
    var managers = [
        { departmentId: "1", value: "Dep 1 Manager 1"},
        { departmentId: "1", value: "Dep 1 Manager 2"},
        { departmentId: "1", value: "Dep 1 Manager 3"},
        { departmentId: "1", value: "Dep 1 Manager 4"},
        { departmentId: "1", value: "Dep 1 Manager 5"},
        { departmentId: "1", value: "Dep 1 Manager 6"},
        { departmentId: "1", value: "Dep 1 Manager 7"},
        { departmentId: "1", value: "Dep 1 Manager 8"},
        { departmentId: "1", value: "Dep 1 Manager 9"},
        { departmentId: "1", value: "Dep 1 Manager 10"},
        { departmentId: "2", value: "Dep 2 Manager 1"},
        { departmentId: "2", value: "Dep 2 Manager 2"},
        { departmentId: "2", value: "Dep 2 Manager 3"},
        { departmentId: "2", value: "Dep 2 Manager 4"},
        { departmentId: "2", value: "Dep 2 Manager 5"},
        { departmentId: "2", value: "Dep 2 Manager 6"},
        { departmentId: "2", value: "Dep 2 Manager 7"},
        { departmentId: "2", value: "Dep 2 Manager 8"},
        { departmentId: "2", value: "Dep 2 Manager 9"},
        { departmentId: "2", value: "Dep 2 Manager 10"}
    ];
    
    function getManagers() {
        $managers.empty();
    
        var departmentId = $departments.val();
    
        for (i = 0; i < managers.length; i++) {
            if (managers[i].departmentId === departmentId) {
                $managers.append("<option value='" + managers[i].departmentId + "'>" + managers[i].value + "</option>");
            }
        }
    }
    
    for (i = 0; i < departments.length; i++) {
        $departments.append("<option value='" + departments[i].id + "'>" + departments[i].value + "</option>");
    }
    
    getManagers();
    
    $departments.on("change", function(){
        getManagers();
    });
    

    I have hard-coded the department and manager sources as I don’t have a database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in my database, one is Transactions and the other is
i have two tables in my database one is A other one is B
I have two MySQL database tables: one containing a list of championships and another
I have two tables in MySql database, one is sales_order and the other is
I have two tables in the database one contains a list of all possible
I have two tables in my MySQL database, one is a library of all
I have two related tables in my database: Page and Tag. One Page can
In a MySQL database I have two tables linked in a join. One table
What I have is two tables inside of a mysql database. One table contains
I have two database tables, one for Users of a web site, containing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.