Rumah > Artikel > pembangunan bahagian belakang > 哪位高手可以写个2级联动select 的例子 看看
谁可以写个2级联动select 的例子 看看
写个简单的例子 写一下注释 研究一下 谢了 各位大虾
------解决方案--------------------
function college2subject(collegeid)
{
var allcount=0;
subjectArray=new Array();
$link=mysql_connect("localhost","root","123");
$db_selected=mysql_select_db("test");
mysql_query("SET NAMES utf8");
$sql="select * from subject";
$result=mysql_query($sql);
$count=0;
while($myrow=mysql_fetch_array($result))
{
echo "subjectArray[".$count."]=new Array('".$myrow['subject_id']."','".$myrow['subject_name']."',
'".$myrow['college_id']."')\n";
$count++;
}
echo "allcount=$count;";
?>
document.studentform.subject.length=0;
document.studentform.subject.options[document.studentform.subject.length]=new Option("所有专业","");
var college_id=collegeid;
var i;
for(i=0;i
if(subjectArray[i][2]==college_id)
{
document.studentform.subject.options[document.studentform.subject.length]=new Opiton(subjectArray[i][1],subjectArray[i][0]);
alert("ok");
}
}
}
alert("ok");