谁可以写个2级联动select 的例子 看看 写个简单的例子 写一下注释 研究一下 谢了 各位大虾 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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']."')\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<allcount;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></head><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()); ?><form id="studentform" name="studentform" method="post" action=""><table width="200" border="1"> <tr> <td>请选择学院</td> <td> <label> <select name=college" onChange="college2subject(this.options[this.selectedIndex].value)"> <option>所有学院</option> <?php while($myrow1=mysql_fetch_array($result)) { ?> <option value="<?php echo $myrow1["college_id"];?>" selected="selected"> <?php echo $myrow1["college_name"];?></option> <?php } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>select筛选_water</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></head><body><span>板块</span><select name="water1" id = "water1"> <option value="" selected>请选择</option> <option value="water1">water1</option> <option value="water2">water2</option> <option value="water3">water3</option> <option value="water4">water4</option> <option value="water5">water5</option></select><span>二级板块</span><select name="water2"> <option value="" selected>请选择</option> <option value="water5-5" rel="water5">water5-5</option> <option value="water5-6" rel="water5">water5-6</option> <option value="water5-7" selected="selected">water5-7</option></select><script type="text/javascript">var $ = function(id){return document.getElementById(id);};(function(){ var dateop = {}; var manage = $('water2'); var options = manage.options; for(var i=0;i<options.length;i++){ var rel = options[i].getAttribute('rel'); if(!rel) continue; if(typeof dateop[rel] == 'undefined') dateop[rel] = []; dateop[rel].push({'value':options[i].value,'text':options[i].text}); }; $('water1').onchange = function(){change();}; function change(){ var type = $('water1').value; var ttname = manage.value; manage.options.length = 1; if(type && typeof dateop[type]){ for(var i=0;i<dateop[type].length;i++){ manage.options.add(new Option(dateop[type][i]['text'], dateop[type][i]['value'])); if(manage.options[i].value == ttname){ manage.options[i].selected = true } } }else{ for(var j in dateop){ if(typeof dateop[j] != 'object') continue; for(var i=0;i<dateop[j].length;i++){ manage.options.add(new Option(dateop[j][i]['text'], dateop[j][i]['value'])); if(manage.options[i].value == ttname){ manage.options[i].selected = true } } } } } change();})();</script></body></html> 两个项目(分别在两台服务器上),怎么给它们做同一个登陆功能呢?求思路 新手,指点一下,如果我做好了静态网页,怎么连接到php后台里 求一个正则表达式 关于 数组插入带键的项 SmartTemplate一个非常大的bug:可以在模版中使用<?代码 数值型字段如何实现全部+1 mysql有这样的统计方法吗?在线等. 加入软件开发交流群,QQ群号为:529604,519356!!! 新手提问session问题? 如何做二级域名解析与在线申请邮箱? PHP连接MSSQL数据库错误 急急急急 readfile binary(图片)文件头会多出一位(0x0A)来.
{
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']."')\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<allcount;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>
</head><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());
?><form id="studentform" name="studentform" method="post" action="">
<table width="200" border="1">
<tr>
<td>请选择学院</td>
<td>
<label>
<select name=college" onChange="college2subject(this.options[this.selectedIndex].value)">
<option>所有学院</option>
<?php
while($myrow1=mysql_fetch_array($result))
{
?>
<option value="<?php echo $myrow1["college_id"];?>" selected="selected">
<?php echo $myrow1["college_name"];?></option>
<?php } ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>select筛选_water</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
</head>
<body>
<span>板块</span>
<select name="water1" id = "water1">
<option value="" selected>请选择</option>
<option value="water1">water1</option>
<option value="water2">water2</option>
<option value="water3">water3</option>
<option value="water4">water4</option>
<option value="water5">water5</option>
</select>
<span>二级板块</span>
<select name="water2">
<option value="" selected>请选择</option> <option value="water5-5" rel="water5">water5-5</option>
<option value="water5-6" rel="water5">water5-6</option>
<option value="water5-7" selected="selected">water5-7</option>
</select>
<script type="text/javascript">
var $ = function(id){return document.getElementById(id);};(function(){ var dateop = {}; var manage = $('water2'); var options = manage.options; for(var i=0;i<options.length;i++){ var rel = options[i].getAttribute('rel'); if(!rel) continue; if(typeof dateop[rel] == 'undefined') dateop[rel] = []; dateop[rel].push({'value':options[i].value,'text':options[i].text}); }; $('water1').onchange = function(){change();}; function change(){ var type = $('water1').value; var ttname = manage.value; manage.options.length = 1; if(type && typeof dateop[type]){ for(var i=0;i<dateop[type].length;i++){ manage.options.add(new Option(dateop[type][i]['text'], dateop[type][i]['value'])); if(manage.options[i].value == ttname){ manage.options[i].selected = true } } }else{ for(var j in dateop){ if(typeof dateop[j] != 'object') continue; for(var i=0;i<dateop[j].length;i++){ manage.options.add(new Option(dateop[j][i]['text'], dateop[j][i]['value'])); if(manage.options[i].value == ttname){ manage.options[i].selected = true } } } } } change();})();</script>
</body>
</html>