You where on the right track with javascript. The secert is to load a javascript array dynamically with php. Below a script that I developed for double drop down menus. You will have to hack it a bit to so that you can populate it it from PHP and fit what you need.
<script language="JavaScript">
var subgenera = new Array();
var subtypes =new Array();
subgenera[1]='grunge';
subtypes[1]=1;
subgenera[2]='pop';
subtypes[2]=1;
subgenera[3]='trance';
subtypes[3]=2;
subgenera[4]='pop';
subtypes[4]=3;
var subgeneras=5;changeoptions();
function changeoptions() {
var item=document.CD.genera.selectedIndex+1;
var x=0;
var p=0;
for(i=1;i<subgeneras;i++) {
if (item==subtypes) {
document.CD.subgenera.options[x]=Option(subgenera,value=i);
if ((item==0) & (i==0)) {
p=x;
}
x=x+1;
}
}
document.CD.subgenera.length=x;
document.CD.subgenera.selectedIndex=p;
}
//-->
</script>
<form name="CD">
<select name="genera" onChange="changeoptions()">
<option value=1>rock and roll</option><option value=2>techno</option><option value=3>country</option></select>
</font></td>
</tr>
<tr>
<td width="25%">sub-genera</td>
<td width="75%"><select name="subgenera"></select></td>
</form>