...

View Full Version : need help on DDL dependencies



korssane
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

COURSE and STUDENT

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

i.e

1st DDL :

MATHS


2nd DDL will see all studen taking that crse :

Mathew
Paul
Susane
..


thanks

xelawho
09-15-2011, 11:15 PM
http://javascript.internet.com/navigation/connected-dropdown-box.html

korssane
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

thanks

xelawho
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?

niralsoni
09-17-2011, 01:33 AM
http://www.codingforums.com/showthread.php?p=1134742#post1134742

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

korssane
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...


thanks

xelawho
09-17-2011, 02:43 AM
:eek:

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:



[1]
[10,10,10,5,5,11];

[2]
[10,5,5,11,10,10];

[3]
[5,5,11,10,10,10];



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:

korssane
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 ...


thanks

xelawho
09-17-2011, 03:24 AM
so...


[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?

korssane
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.

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


<!DOCTYPE html>
<html>
<head>
<title>blank</title>
<meta charset="UTF-8">
</head>

<body>




<script type="text/javascript">
function populate(o) {
d=document.getElementById('de');
if(!d){return;}
var mitems=new Array();
mitems['Project 1']=['Select Gate','gate 11', 'gate 12', 'gate 13'];
mitems['Project 2']=['Select Gate','gate 21', 'gate22', 'gate23'];
d.options.length=0;
cur=mitems[o.options[o.selectedIndex].value];
if(!cur){return;}
d.options.length=cur.length;
for(var i=0;i<cur.length;i++) {
d.options[i].text=cur[i];
d.options[i].value=cur[i];
}
}

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

function clearDiv() {
document.getElementById('results').innerHTML=""
}
</script>


<form>
<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>
</select>
<label for="de">Choose a gate:</label>
<select name="de" id="de" onchange="show()">
<option selected>Select Gate</option></select>
</form>

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum