用“select Name from users”sql语句从数据库里取出系;然后当第一个下拉框改变选择的时候,根据id或者系名在用sql语句从数据库里取出该系的所有专业就行了
http://www.sayee.com/cloudchen/js/thirdChange.htm
楼上说的不错,我这儿有一个,不过没用二维数组。 <script language=javascript> <!-- var arrItems2 = new Array(); var arrItemsGrp2 = new Array(); var arrItems3 = new Array(); var arrItemsGrp3 = new Array(); <%for i=0 to ubound(arrItems2)%> <%if arrItems2(i)="" then exit for%> arrItems2[<%=i%>]='<%=arrItems2(i)%>' <%next%><%for i=0 to ubound(arrItemsGrp2)%> <%if arrItemsGrp2(i)="" then exit for%> arrItemsGrp2[<%=i%>]='<%=arrItemsGrp2(i)%>' <%next%><%for i=0 to ubound(arrItems3)%> <%if arrItems3(i)="" then exit for%> arrItems3[<%=i%>]='<%=arrItems3(i)%>' <%next%><%for i=0 to ubound(arrItemsGrp3)%> <%if arrItemsGrp3(i)="" then exit for%> arrItemsGrp3[<%=i%>]='<%=arrItemsGrp3(i)%>' <%next%> function selectChange(control, controlToPopulate, ItemArray, GroupArray) { var myEle ; var x ; // Empty the second drop down box of any choices for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null; if (control.name == "select2") { // Empty the third drop down box of any choices for (var q=myChoices.select3.options.length;q>=0;q--) myChoices.select3.options[q] = null; } // ADD Default Choice - in case there are no values
myEle = document.createElement("option") ; myEle.value = 0 ; myEle.text = "[SELECT]" ; controlToPopulate.add(myEle) ;for ( x = 0 ; x <ItemArray.length; x++ ) { str=GroupArray[x] if (GroupArray[0].length==5) aa=str.substring(0,3) else{ aa=str.substring(0,5)
<script language=javascript>
<!--
var arrItems2 = new Array();
var arrItemsGrp2 = new Array();
var arrItems3 = new Array();
var arrItemsGrp3 = new Array();
<%for i=0 to ubound(arrItems2)%>
<%if arrItems2(i)="" then exit for%>
arrItems2[<%=i%>]='<%=arrItems2(i)%>'
<%next%><%for i=0 to ubound(arrItemsGrp2)%>
<%if arrItemsGrp2(i)="" then exit for%>
arrItemsGrp2[<%=i%>]='<%=arrItemsGrp2(i)%>'
<%next%><%for i=0 to ubound(arrItems3)%>
<%if arrItems3(i)="" then exit for%>
arrItems3[<%=i%>]='<%=arrItems3(i)%>'
<%next%><%for i=0 to ubound(arrItemsGrp3)%>
<%if arrItemsGrp3(i)="" then exit for%>
arrItemsGrp3[<%=i%>]='<%=arrItemsGrp3(i)%>'
<%next%>
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null; if (control.name == "select2") {
// Empty the third drop down box of any choices
for (var q=myChoices.select3.options.length;q>=0;q--) myChoices.select3.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle) ;for ( x = 0 ; x <ItemArray.length; x++ )
{
str=GroupArray[x]
if (GroupArray[0].length==5)
aa=str.substring(0,3)
else{
aa=str.substring(0,5)
}
if ( aa == control.value )
{
myEle = document.createElement("option") ;
myEle.value =GroupArray[x];
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
-->
</script>