• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 3年前 (2022-01-24) 18次浏览 已收录 0个评论

谁可以写个2级联动select 的例子 看看
写个简单的例子 写一下注释 研究一下 谢了 各位大虾

——解决方案——————–
function college2subject(collegeid)
{
var allcount=0;
subjectArray=new Array();
<?php
$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’].”‘)\/本2文来源[email protected]搞@^&代*@码2网搞gaodaima代码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”);
</script>

<body>
<?php
$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());

?>

请选择学院