apapanic
asked on
How a 2nd combo box loads itself by corresponding to a selection in a 1st combo box using JSP and MS Access
Hi
I have been stuck on this for a few days. Ok this is my environment: MS Access DB, Tomcat Server.
I have a table in MS Access, that I would like to use to populate a combo box. The name of this table is Agency.
Table looks like this with Agency_ID as the Primary Key.
Agency_ID Description
1 Home Inc.
2 Garret, Co.
etc....................
I have another table that is named Contracts with Agency_ID as the foreign key, and Contract_ID as the primary key, looks like this.
Contract_ID Agency_ID Description
1 1 Contract 1
2 1 Contract 2
3 2 Contract 3
4 2 Contract 7
Now, I need to build a JSP page where a user goes in and chooses their Agency from a combo box and then, a combo box containing the Contract Descriptions is automatically populated according to what agency they choose.
For instance, if a user chooses Home Inc, which is in the first combo box, then Contract1, and Contract2 will be populated in the 2nd combo box, displaying the Contract ID descriptions.
I need a pretty detailed answer, since I am a fairly new to Java/JSP/Javascript. I have some understanding of classes, and servlets, etc. The thing I am most concerned about is getting the combo boxes to work dinamically, correctly. I've searched the examples on this site, but they don't use databases to build the combo boxes.
I have been stuck on this for a few days. Ok this is my environment: MS Access DB, Tomcat Server.
I have a table in MS Access, that I would like to use to populate a combo box. The name of this table is Agency.
Table looks like this with Agency_ID as the Primary Key.
Agency_ID Description
1 Home Inc.
2 Garret, Co.
etc....................
I have another table that is named Contracts with Agency_ID as the foreign key, and Contract_ID as the primary key, looks like this.
Contract_ID Agency_ID Description
1 1 Contract 1
2 1 Contract 2
3 2 Contract 3
4 2 Contract 7
Now, I need to build a JSP page where a user goes in and chooses their Agency from a combo box and then, a combo box containing the Contract Descriptions is automatically populated according to what agency they choose.
For instance, if a user chooses Home Inc, which is in the first combo box, then Contract1, and Contract2 will be populated in the 2nd combo box, displaying the Contract ID descriptions.
I need a pretty detailed answer, since I am a fairly new to Java/JSP/Javascript. I have some understanding of classes, and servlets, etc. The thing I am most concerned about is getting the combo boxes to work dinamically, correctly. I've searched the examples on this site, but they don't use databases to build the combo boxes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't want to use Java Script..I need JSP code
ASKER
So when someone chooses....Agency "Home, Inc." then a Contracts combo box is populated and enabled to choose, Contract 1, and Contract 2. But the code needs to be using the Agency_ID and Contract_ID fields to do this. I also plan on using SQL for the dropdowns, because when the database changes, the dropdowns will change accordingly.
Here is my database once again from my original question...Let's call it "WorkData.mdb
Agency_ID Description
1 Home Inc.
2 Garret, Co.
etc....................
Contract_ID Agency_ID Description
1 1 Contract 1
2 1 Contract 2
3 2 Contract 3
4 2 Contract 7