Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my project I have two dropdowns in my jsp origin and destination .The first dropdown origin gets populated from databse and second one is dependent on first.Please provide the code without ajax using only jdbc and jsp . The data from database is in a resultset .

The following code snippet of for the storage of data from database in a result set :-
Java
while (rsRegions.next())
{
    previousSubRegion = departsSubRegion;
    departsSubRegion = rsRegions.getString("DEPARTS_SUB_REGION");
    arrivesSubRegion = rsRegions.getString("ARRIVES_SUB_REGION");
    reportName = rsRegions.getString("REPORT_NAME");
    downloadLink = roiURL + reportName + roisufix;
}

I want to store the above variables(departsSubRegion) in an arrayList and then bind them to one drop down and then store another variable (arrivesSubRegion) which will be selected on the basis of the first selection (cascading drop-down)
Posted
Updated 16-May-13 19:54pm
v3
Comments
Shubhashish_Mandal 16-May-13 4:49am    
Do you believe that someone in codeproject will write your code ?
gryffin31 16-May-13 6:01am    
I have an idea and have also pened down most of it.wanted to gather some more idea.If I wnt get there is no choice
Shubhashish_Mandal 16-May-13 7:22am    
let us know what you have tried and where you stuck.
Prasad Khandekar 17-May-13 2:02am    
Hello Gryffin,

How these two data items related to each other? What's the problem in storing the departsSubRegion values in ArrayList? I hope that your query has a ORDER BY DEPARTS_SUB_REGION, ARRIVES_SUB_REGION clause for you to be able to create these two array lists. For arrivesSubRegion try to use a JSON structure with the key as value of previousSubRegion and value being an array of arrivesSubRegion. On change of departsSubRegion you will have to create a new array for arrivesSubRegion and at populate the eariler array in JSON structure. The actual population of arrivesSubRegion combo will be done in javascript using the JSON structure. Your final json structure for arrivesSubRegion will look something like one shown below.
{
"DEPARTS_SUB_REGION_1": [
"ARRIVES_SUB_REGION_1",
"ARRIVES_SUB_REGION_2",
"ARRIVES_SUB_REGION_3",
"ARRIVES_SUB_REGION_4"
],
"DEPARTS_SUB_REGION_2": [
"ARRIVES_SUB_REGION_5",
"ARRIVES_SUB_REGION_6",
"ARRIVES_SUB_REGION_7",
"ARRIVES_SUB_REGION_8"
],
...
}

Regards,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900