Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I'm having problems trying to figure out how to ping point my second DropDownMenu from a selection on the first DropDownMenu. Both are populated from a SQL Database with similar records for both rows.

Exe:

Table tblABC

Systems
====
AAA
CCC
AAA
AAA
AAA
XXX
CCC
XXX

Types
====
12345
23333
23333
23333
23333
12345
44444
44444

so in the site the user needs to select a System then needs to Select a Type based by the selection of the System that will have that selection.

Exe.

first dropdownmenu = System AAA

second dropdownmenu will display all the types of System AAA
that could be
12345
23333
and so on
the user will click on that type selection and based on that it will display all columns for that selection.

Exe:

User selection:
System: AAA / Type: 12345 / Group: CCCCCCCCC / Description: Bla Bla Bla


I also want to point out that Group row in tables have repetitive records as well... same with Systems and Type.

I hope this explains a bit my situation... Thanks all for your help
Posted

1 solution

I'd probably populate the first drop down as you would normally. (Gawd, let me see if I remember by Classic ASP)

Something like:
<%
Response.Write("<SELECT id='ddParent' onchange='populateSecondDropDown();'>")
Response.Write("<OPTION>" & Row("system_id") & "'</OPTION>")
Response.Write("</SELECT>")
%>


Then I would write the list of the child items to some sort of JavaScript structure that associated the parent with the child:

(Note, this is pseudo-code JavaScript. No guarantees are made here!)
<SCRIPT>
var childItems = <%

'Loop through the RecordSet that contains child and parent records

%>;
</SCRIPT>


so that the result would look something like this in JSON format:
var childItems = {"System AAA": {"12345", "23333"}};


Finally, I'd write the function associated with the change in the parent dropdown populateSecondDropDown().

<SCRIPT>
function populateSecondDropDown(){
var dropDown = document.getElementById("ddParent");

//clear out elements
dropDown.innerHtml = "";

//populate the dropDown variable with new options from the childItems structure variable.

}
</SCRIPT>
 
Share this answer
 
v2

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