View Full Version : need help on DDL dependencies

09-15-2011, 11:10 PM
Hi peers ,

i have 2 tables

the 1st one "COURSE" has the follwoing :

Course (ID) : unique / Course name / Course Type
1 / physics / sc
2 / Chemistry / sc
3/ maths / mt

the 2nd table "STUDENT" has the follwoing "

ID (unique ) / Name / Fname / course ID / Course Name /

i have the both tables loaded already in a javascript


i have a dropdown list created that gives me all COURSE list ITEMS ..

what i want is : another dropdownlist that shows me all distinct names "student" that are taking that course


1st DDL :


2nd DDL will see all studen taking that crse :



09-15-2011, 11:15 PM

09-16-2011, 05:39 AM
hi Xelawho ,

Thanks for the quick reply . the link is very hepfull but i am unable to adapt it to my case here :

let say i have 3 javascrit arrays that holds 3 field data

projectid[] / projectname[] / projectType []

1st record :

projectid[0]=1 / projectname[0]=project1 / projectType [0] =M
projectid[1]=2 / projectname[1]=project2 / projectType [1] =L

and so on...

project type can holds up to 4 values ( Not changing : M, O, K, L)

We have 2 other DDLs with diff elements that we need to call based on projecttype
if (M i will call TDDL1)
if (O i will call TDDL2)
if (K i will call TDDL1)
if (L i will call TDDL2)

1- i am creating a form where the user has 2 dropdownlists where he can choose in the 1st one the projectname .
2- Once he chooses the name and based on projecttype of this course name chosen.
He will get different values to pick up on the 2nd dropdownlist based on the projecttype

let say he chooses project1 in the 1st DDL , which means projectType [0] =M
based on the M, he will get TDDL1 items in the 2nd DDL.

sorry if iam unclear ..but if you can help that will be appreciated


09-16-2011, 05:51 AM
ah, yes... I think I remember something about your project names :eek:

so... there are 3 arrays, and 2 DDLs? But the Project ID is tied to the Project name... ie ID 1 will always be project 1, ID2 will always be project 2, etc?

no... wait... the project ID is tied to the project type?

or are there 3 DDLs?

and what's a TDDL?

and (being that you're probably going to have to show them at some point anyway), can't you give us a sample of your 3 arrays like you did last time?

09-17-2011, 01:33 AM

check this link... might be a useful reference..

09-17-2011, 02:20 AM
hi Xelawho ,

sorry iw as away for the whole day.

a record is compsed of 3 elements :
Projectid / Projectname / ProjectType and each of them are constituing an array ...i f i want to check record 1 , then i have to check

Record 1 : Projectid[0]/ Projectname[0] / ProjectType [0].

ProjectType can get one of the 3 items (M,L,P) .
In other hand i have 2 DDLs ( TDDL1, TDDL2)

and based on the ProjectType value i want to show whether TDDL1 or TDDL2

let say ProjectType [1]="M" i will have to show TDDL1 items
if ProjectType [1]="P" i will have to show TDDL2 items

hope this clarify ...simpy i want to display one DDL based on element of a previous one...


09-17-2011, 02:43 AM

I think I was less confused before the explanation

just gimme 4 items out of each of the three arrays. If you want to give them as arrays and save me the typing, thanks. Like this:
var ProjectId = [1,2,3,4,5,6];

then we need to know which is the first DDL, what does it show (ie, which array)?

and if you choose an item from there, what does it then show?

so maybe you can format this like this:




then we need to know:
1 what happens when you select an item from the 2nd DDL?
2 what are you doing with the other array?
3 what's a TDDL?

apart from that it's all completely clear :thumbsup:

09-17-2011, 03:19 AM
Well, nothing will happens. i will use the values and insert them into a db.

it is just a matter of choosing the the right DDL to display based on the previous DDL Item selected. As iam working with projects, each project type has its own project gates
let says i have the 1st DDL1 woth project 1 / projkect2/project3 as items
with respective project types type1, type2 and type3...

the next DDL2 will show project gate information based on the project "type" of the previous DDL1
if i have selected project 1 in DDL1 ..means i have type 1 and if i have type1

next DDL2 will display (gatet11, gate12, gate13)

if i choose project 2 in DDL1 ..means i have type2 and if i have type2

DDL2 in this case will show other items (gatet21, gate22, gate23)

and so ...


09-17-2011, 03:24 AM

[Project 1]
[gatet11, gate12, gate13];

[Project 2]
[gatet21, gate22, gate23];

because "type" doesn't really matter - Project 1 will always be type 1, project 2 will always be type 2, etc?

09-17-2011, 03:55 AM
Yes, once the project is created it will be assigned a type initially type1 , type2 or type 3 and it will keep that type.

09-17-2011, 04:12 AM
so why is it not like this?

<!DOCTYPE html>
<meta charset="UTF-8">


<script type="text/javascript">
function populate(o) {
var mitems=new Array();
mitems['Project 1']=['Select Gate','gate 11', 'gate 12', 'gate 13'];
mitems['Project 2']=['Select Gate','gate 21', 'gate22', 'gate23'];
for(var i=0;i<cur.length;i++) {

function show() {
document.getElementById('results').innerHTML=document.getElementById('or').value+" "+document.getElementById('de').value;

function clearDiv() {

<label for="or">Choose a project:</label>
<select name="or" id="or" onchange="populate(this); clearDiv()">
<option selected value="Choose">Select Project</option>
<option value="Project 1">Project 1</option>
<option value="Project 2">Project 2</option>
<label for="de">Choose a gate:</label>
<select name="de" id="de" onchange="show()">
<option selected>Select Gate</option></select>

<div id="results"></div>