Home  >  Article  >  Backend Development  >  哪位高手可以写个2级联动select 的例子 看看

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

WBOY
WBOYOriginal
2016-06-13 10:12:251060browse

谁可以写个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());

?>





请选择学院
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn