【转】asp二级联动的数据库版。
<script language = "javas
var j;
j=0;
goaler = new Array();
<%set rs=conn.execute("select * from SmallClass order by SmallClassID")
if rs.eof then%>
goaler[0] = new Array("无分类","","");
<%else
i=0
do while not rs.eof%>
goaler[<%=i%>] = new Array("<%=rs("SmallClassName")%>","<%=rs("BigClassID")%>","<%=rs("SmallClassID")%>");
<%rs.movenext
i=i+1
loop
end if
rs.close
%>
j=<%=i%>;
function changelocation(locationid)
{
document.goalerform.SmallClassID.length = 0;
var locationid=locationid;
var i;
for (i=0;i < j; i++)
{
if (goaler[i][1] == locationid)
{
document.goalerform.SmallClassID.options[document.goalerform.SmallClassID.length] = new Option(goaler[i][0], goaler[i][2]);
}
}
}
</script>
<form method="post" name="goalerform" act
<select name="BigClassID" on
<%set rs=conn.execute("select * from BigClass order by BigClassID")
if rs.eof then%>
<option selected value="">无一级分类</option>
<%else%>
<option selected value="">请选择一级分类</option>
<%do while not rs.eof%>
<option value="<%=rs("BigClassID")%>"><%=rs("BigClassName")%></option>
<%rs.movenext
loop
end if%>
</select>
<select name="SmallClassID">
<option selected value="">未指定一级分类</option>
</select>
<input type="submit" name="goaler" value="提交">
</form>
<%'测试取值
if request("goaler")<>"" then
response.write "BigClassID="&request("BigClassID")&"<BR>SmallClassID="&request("SmallClassID")
end if%>
--------==========================================================-----------------------
可能程序还有其它的同名的RECORDSET,为防止影响。可以改为
<%
SmallClassID=request.form("SmallClassID")
if
set
if
end
dansin.close
else
response.write("SmallClassID值为空")
end
<!--
<%
SmallClassID=request.form("SmallClassID")
if
set
if
end
else
response.write("SmallClassID值为空")
end
rs.close
conn.close
%>