表:ANclass
Nclassid Nclass classID
3 脚本的应用 3
4 SQL常见查询 3
6 精华帖子 3
7 JSP初级指导 4
8 SQL基础 5
9 数据库管理 5
-----------------------------------
表:Aclass
classID class
3 ASP专区
4 JSP专区
5 数据库专区
-------------------------------------------
代码:
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from ANclass order by Nclassid asc"
rs.open sql,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"))%>","<%= trim(rs("classid"))%>","<%= trim(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)
{
alert(locationid)
alert("haha");
//alert(subcat[i][0]);
alert(subcat[i][2])
//alert(subcat[i][2]);
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<br><br>
<form method="POST" name="myform" action="adminsave.asp?action=add">
<div align="center"><center><table cellspacing="0" width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999">
<tr>
<td width="100%" bgcolor="#999999" height="20"><font color="#FFFFFF"><center><p><b>添 加 文 章</b></font></td>
</tr>
<tr align="center">
<td width="100%">
<table border="0" cellspacing="1" width="100%">
<tr>
<td width="15%" align="right" valign="top" height="20"><b>文章类型:</b></td>
<td width="85%">
<%
sql = "select * from Aclass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="classid" onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("classid"))%>"><%=trim(rs("class"))%></option>
<% dim selclass
selclass=rs("classid")
response.Write selclass
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("classid"))%>"><%=trim(rs("class"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<%=selclass%> <select name="Nclassid">
<%sql="select * from ANclass where classid="&selclass
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("NclassID")%>"><%=rs("Nclass")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("NclassID")%>"><%=rs("Nclass")%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
</select>**
<%response.Write selclass%>
</td></tr>