var combo1=new Array()
combo1[0]=new Option(" =เลือกวิชา=","")
<?
$sqlsub="Select * From subject where clas='$clas' order by sub_id";
$resultsub=mysql_db_query($db,$sqlsub);
$j=1;
while($rssub= mysql_fetch_array($resultsub))
{
Echo "combo1[$j]=new Option(\"$rssub[sub_id] : $rssub[sub_name]\",\"$rssub[sub_id]\")\n";
$j++;
}
?>
var combo2=new Array()
combo2[0]=new Option(" =เลือกวิชา=","")
<?
$sqlsub="Select * From subject order by sub_id";
$resultsub=mysql_db_query($db,$sqlsub);
$j=1;
while($rssub= mysql_fetch_array($resultsub))
{
Echo "combo2[$j]=new Option(\"$rssub[sub_id] : $rssub[sub_name]\",\"$rssub[sub_id]\")\n";
$j++;
}
?>
var cacheobj1=document.form1.subj1
var cacheobj2=document.form1.subj2
var cacheobj3=document.form1.subj3
var cacheobj4=document.form1.subj4
var cacheobj5=document.form1.subj5
function populate(x)
{
for (m=cacheobj1.options.length-1;m>0;m--)
cacheobj1.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj1.options=new Option(selectedarray.text,selectedarray.value)
cacheobj1.options[0].selected=true
for (m=cacheobj2.options.length-1;m>0;m--)
cacheobj2.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj2.options=new Option(selectedarray.text,selectedarray.value)
cacheobj2.options[0].selected=true
for (m=cacheobj3.options.length-1;m>0;m--)
cacheobj3.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj3.options=new Option(selectedarray.text,selectedarray.value)
cacheobj3.options[0].selected=true
for (m=cacheobj4.options.length-1;m>0;m--)
cacheobj4.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj4.options=new Option(selectedarray.text,selectedarray.value)
cacheobj4.options[0].selected=true
for (m=cacheobj5.options.length-1;m>0;m--)
cacheobj5.options[m]=null
selectedarray=eval(x)
for (i=0;i<selectedarray.length;i++)
cacheobj5.options=new Option(selectedarray.text,selectedarray.value)
cacheobj5.options[0].selected=true
}
function displaysub1(){
populate(combo1)
}
function displaysub2(){
populate(combo2)
}
populate(combo1)