这是一段修改信息的页面, 只有大类的时候 可以调出数据, 有了小类,就会超过了脚本运行的最长时间!!
<%
dim id
id=request.QueryString("id")
if not isnumeric(id) then
response.write"<script>alert(""非法访问!"");location.href=""../index.asp"";</script>"
response.end
end if
%>
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from SmallClass_New order by SmallClassID asc",conn,1,1
%>
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= rs("BigClassName")%>","<%= rs("SmallClassName")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
//-->
</script>
<form name="myform" method="post" action="addnew.asp?action=edit&id=<%=id%>">
<td>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
<tr >
<td width="21%" align="right">选择分类:</td>
<td width="79%">大类:
<%dim rs1
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from News where id="&id,conn,1,1
rs.open "select * from BigClass_New order by BigClassID asc",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)">
<%
do while not rs.eof
%>
<option value="<%=rs("BigClassName")%>" <%if rs1("BigClassName")=rs("BigClassName") then%>selected<%end if%>><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
小类:
<select name="SmallClassName">
<%
rs.open "select * from SmallClass_New where BigClassName="&rs1("BigClassName"),conn,1,1
if not(rs.eof and rs.bof) then
do while not rs.eof%>
<option value="<%=rs("SmallClassName")%>"<%if rs1("SmallClassName")=rs("SmallClassName") then %> selected <%end if %> ><%=trim(rs("SmallClassName"))%></option>
<% rs.movenext
loop
end if
rs.close
set rs= nothing
%>
</select>
[此贴子已经被作者于2007-6-29 10:29:22编辑过]