热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

哪位高手可以写个2级联动select的例子看看-php教程

谁可以写个2级联动select的例子看看写个简单的例子写一下注释研究一下谢了各位大虾------解决方案--------------------functioncollege2subject(collegeid){varallcount0;subjectArraynewArray();<?php$linkmysq
谁可以写个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");






$link=mysql_connect("localhost","root","123");
$db_selected=mysql_select_db("test");
mysql_query("SET NAMES utf8");

$sql="select * from college";

$result=mysql_query($sql)or die (mysql_error());

?>





请选择学院