anarn大楼:asp 列表的问题 高手进来!

来源:百度文库 编辑:高考问答 时间:2024/04/29 05:13:14
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from w163_sort2 order by Nclassidorder ",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%= rs("anclassid")%>","<%= rs("Nclassid")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>

onecount=<%=count%>;

function changelocation(locationid)
{
document.myform.Nclassid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from w163_pingpai order by pingpaiorder ",conn,1,1%>
<script language = "JavaScript">
var onecount1;
onecount1=0;
subcat1 = new Array();
<%
count = 0
do while not rs.eof
%>
subcat1[<%=count%>] = new Array("<%= trim(rs("pingpainame"))%>","<%= rs("nclassid")%>","<%= rs("id")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>

onecount1=<%=count%>;

function changelocation1(locationid1)
{
document.myform.select1.length = 0;

var locationid1=locationid1;
var i;
for (i=0;i < onecount1; i++)
{
if (subcat1[i][1] == locationid1)
{
document.myform.select1.options[document.myform.select1.length] = new Option(subcat1[i][0], subcat1[i][2]);
}
}

}
</script>

<script language = "JavaScript">
……
……
</script>
是运行在客户端的。它的性质决定它不能这样和<% %>中的数据公用。

如果你想这样运行的话。建议你用
response.write("<script language = ""JavaScript"" & vbcrlf>
")
……
……
response.write("<script language = ""JavaScript"">
" & vbcrlf)