|
谢谢tz-chf的关注!!!
我也是才学的做ASP所以好多不明白!
这是我在网上找到的,谁能帮我把其对应的数据库建起来啊!?
<!--#i nclude file="inc/Conn.asp"-->
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim rs5
dim sql5
dim count
dim rs6
dim sql6
dim rs7
dim sql7
dim count2
Set rs5 = Server.CreateObject("ADODB.RecordSet")
sql5 = "select * from unit"
rs5.Open sql5,conn,1,1
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs5.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs5("unitname"))%>","<%= trim(rs5("subjid"))%>","<%= trim(rs5("id"))%>");
<%
count = count + 1
rs5.movenext
loop
rs5.close
set rs5=nothing
%>
onecount=<%=count%>;
function changelocation(subjid)
{
document.form1.unitid.length = 0;
var subjid=subjid;
var i;
document.form1.unitid.options[0] = new Option('请选择单元','');
for (i=0;i < onecount; i++)
{
if (subcat[1] == subjid)
{
document.form1.unitid.options[document.form1.unitid.length] = new Option(subcat[0], subcat[2]);
}
}
}
</script>
<%
Set rs7 = Server.CreateObject("ADODB.RecordSet")
sql7 = "select * from setion"
rs7.Open sql7,conn,1,1
%>
<script language = "JavaScript">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
count2 = 0
do while not rs7.eof
%>
subcat2[<%=count2%>] = new Array("<%= trim(rs7("sectionname"))%>","<%= trim(rs7("unitid"))%>","<%= trim(rs7("id"))%>");
<%
count2 = count2 + 1
rs7.movenext
loop
rs7.close
set rs7=nothing
%>
onecount2=<%=count2%>;
function changelocation2(id)
{
document.form1.sectionid.length = 0;
var id=id;
var j;
document.form1.sectionid.options[0] = new Option('请选择章节','');
for (j=0;j < onecount2; j++)
{
if (subcat2[j][1] == id)
{
document.form1.sectionid.options[document.form1.sectionid.length] = new Option(subcat2[j][0], subcat2[j][2]);
}
}
}
</script>
</head>
<body>
<form name="form1" method="post">
<br>
<select name="subjid" onChange="changelocation(document.form1.subjid.options[document.form1.subjid.selectedIndex].value)" size="1">
<option selected>请选择科目</option>
<%
sql6 = "select * from subject"
set rs6 = conn.Execute (sql6)
do while not rs6.eof
%>
<option value="<%=trim(rs6("id"))%>"><%=trim(rs6("subjName"))%></option>
<%
rs6.movenext
loop
rs6.close
set rs6 = nothing
conn.Close
set conn = nothing
%>
</select>
<select name="unitid" onChange="changelocation2(document.form1.unitid.options[document.form1.unitid.selectedIndex].value)">
<option selected value="">==所有单元==</option>
</select>
<select name="sectionid" size="1">
<option selected>==所有章节==</option>
</select>
<br>
</form>
</body>
</html>
方法2
<!--#i nclude file="inc/conn.asp"-->
<%
dim subjectid,unitid
subjectid = request("subjectid") 'subjectid 大类id
unitid = request("unitid") 'unitid 中类id
set rs=server.createobject("adodb.recordset")
sql = "select * from subject" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected >==请选择所属市局==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(subjectid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("subjname") & "</option>"
else
strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("subjname") & "</option>"
end if
rs.movenext
loop
rs.close
if subjectid <> "" then
sql = "select * from unit where subjid=" & subjectid '表二 中类表 bid==表一中的id
rs.open sql,conn,1,1
strOption2 = "<option value='' selected >==请选择所属县局==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(unitid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("unitname") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("unitname") & "</option>"
end if
rs.movenext
loop
rs.close
end if
if unitid <> "" then
sql = "select * from setion where unitid= " & unitid '表三 小类表 mid==表二的id
rs.open sql,conn,1,1
strOption3 = "<option value='' selected >==请选择学校==</option>"
while not rs.eof
if cstr(rs("id")) = cstr(sectionid) then
strOption3 = strOption3 & "<option value='" & rs("id") & "' selected>" & rs("sectionname") & "</option>"
else
strOption3 = strOption3 & "<option value='" & rs("id") & "'>" & rs("sectionname") & "</option>"
end if
rs.movenext
wend
rs.close
end if
%>
<select onchange="changeb(this.value)" name="subjectid"><%=strOption1%></select>
<select onchange="change(this.value)" name="unitid"><%=strOption2%></select>
<select name="sectionid"><%=strOption3%></select>
<script language="javascript">
<!--
function changeb(subjectid){
location.assign("?action=s_s&subjectid=" + subjectid);
}
function change(unitid){
location.assign("?action=s_s&subjectid=<%=subjectid%>&unitid=" + unitid);
}
-->
</script> |
|