怎样从二级联动菜单提交后取出数据?
<%
db_path = "2lian.mdb"
conn_str = "provider=Microsoft.Jet.Oledb.4.0;Data source=" & Server.MapPath(db_path)
err.clear
set conn=server.CreateObject("adodb.connection")
conn.Open conn_str
if err then
response.Write err.description
response.Write "<h1 style=""margin-top:200px;font-size:30px;font-weight:700;text-align:center;color:red;"" onmouseover=""this.style.font-color=blue;"">★数据库连接错误★</h1>"
err.clear
response.End()
end if
set rs = server.CreateObject("adodb.recordset")
function isRb(rs)
if rs.bof and rs.eof then
isrb = true
else
isrb = false
end if
end function
sub ShowErr(ErrStr)
response.Write "<h5 style=""color:#f00;"">"&ErrStr&"</h5>"
response.End()
end sub
sub RsOpen(oRs,sSql,oConn,adOpen,adLock)
on error resume next
if not Isobject(oRs) then call ShowErr("Recordset 对象错误")
if not Isobject(oConn) then call ShowErr("Connection 对象错误")
if sSql="" then call ShowErr("SQL语句为空")
if adOpen="" then call ShowErr("请指定游标[移动]锁定方式")
if adLock="" then call ShowErr("请指定游标[读写]锁定方式")
err.clear
oRs.open sSql,oConn,adOpen,adLock
if err then call ShowErr("Recordset打开错误:"&err.description)
end sub
sub Rso11(oRs,oConn,sSql)
RsOpen oRs,sSql,oConn,1,1
end sub
function dbcombox()
if not isobject(rs3) then set rs3=server.CreateObject("adodb.recordset")
sql = "select id,class_name from classes where depth=1 order by corder"
Rso11 rs3,conn,sql
if not isrb(rs3) then
tt=rs3.recordcount
for ii=1 to tt
msg = msg & "<option>" & rs3(1) & "</option>"&vbcrlf
rs3.movenext
next
end if
rs3.close
set rs3=nothing
dbcombox = msg
end function
function Get1stSubclass()
if not isobject(rs3) then set rs3=server.CreateObject("adodb.recordset")
sql = "select id,class_name from classes where pid=(select top 1 id from classes where depth=1 order by corder)"
Rso11 rs3,conn,sql
if not isrb(rs3) then
i=rs3.recordcount
for ii=1 to i
msg = msg & "<option>" & rs3(1) & "</option>"&vbcrlf
rs3.movenext
next
end if
rs3.close
set rs3=nothing
Get1stSubclass=msg
end function
%>
<form name="regin" method="post" action="">
<select name="pclass" size="1" onChange="SetSubClass(this.options.selectedIndex)"><%=dbcombox()%></select>
<select name="sclass" size="1"><%= Get1stSubclass %></select>
<input type="submit" name="goaler" value="提交">
</form>
<script type="text/javascript">
var groups=document.regin.pclass.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
<%
sql="select id,class_name from [classes] where depth=1 order by corder"
Rso11 rs,conn,sql
if not isrb(rs) then
t=rs.recordcount-1
for i=0 to t
if not isobject(rs2) then set rs2=server.CreateObject("adodb.recordset")
sql2="select id,class_name from [classes] where pid="&rs(0)&" order by corder"
Rso11 rs2,conn,sql2
if not isrb(rs2) then
r=rs2.recordcount-1
for ii=0 to r
response.Write "group["&i&"]["&ii&"]=new Option("""&rs2(1)&""","""&rs2(0)&""")"&vbcrlf
rs2.movenext
next
end if
rs2.close
rs.movenext
next
end if
rs.close
%>
var temp=document.regin.sclass
function SetSubClass(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}
//-->
</script>
<%取值(如何做,请帮忙!!!)
if request("goaler")<>"" then
response.write " "
end if%>
我是在数据库建了一个表,表的格式是这样的:
字段名称 数据类型 说明
ID 自动编号
class_name 文本 分类名称
pid 数字 父类编号
corder 数字 分类顺序
depth 数字 分类深度
id class_name pid corder depth
1 一部 0 1 1
2 二部 0 2 1
3 一科 1 3 2
4 二科 1 4 2
5 三科 2 5 2
6 四科 2 6 2
[此贴子已经被作者于2006-9-12 12:10:43编辑过]