怎样把二级联动菜单改三级?急!

mioho 2009-07-21 08:35:53
先看源码!
<form action="" name="form1" method="post" onSubmit="WBTB_CopyData('Body');">
<tr>
<td colspan="2" align="center" height="30" background="image/tablebg.gif">
<b>新闻发布</b> </td>
</tr>
<tr valign="middle">
<td width="14%" height="25">新闻类别:</td>
<td width="86%" height="25"> <%
set rs = conn.execute("select Unid,classname from News_class where flag = 0 order by enorcn,orderflag asc")
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%> <select name="classid"
<% if secoundY then %>
onChange="changelocation(document.form1.classid.options[document.form1.classid.selectedIndex].value)"
<% end if%>
>
<option value="">选择大类</option>
<%do while not rs.eof%>
<option value="<%=rs(0)%>"><%=Qcdn.HTMLcode(rs(1))%></option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select> <font color="red">
<% if secoundY then %>
<select name="Nclassid">
<option value="">选择小类</option>
</select>
<% else %>

<input type="hidden" name="Nclassid" value="0">
<% end if %>
*</font> <input type="hidden" name="IncFiles" value=""> </td>
</tr>



这个事2级联动,本人要求三级联动。。。请问怎么修改。。。望高手改改看看,十分感谢!
...全文
128 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mioho 2009-07-22
  • 打赏
  • 举报
回复
请问那程序上如何实现?
mioho 2009-07-22
  • 打赏
  • 举报
回复
分类表是这样的:

unid classname flag flag2 orderflag
17 企业介绍 0 0 1 一级栏目
46 联系我们 0 0 8 一级栏目
65 产品中心 0 0 3 一级栏目
67 新闻中心 0 0 4 一级栏目
73 压滤机系列 65 0 1 二级栏目
75 离心机系列 65 0 1 二级栏目
94 监控设备 3 73 1 三级栏目
95 监控器材 3 73 1 三级栏目

unid是自动排列ID, classname是栏目名, flag栏目级别0是一级,3是三级,其他数为二级, flag2是三级栏目的对应上一级的ID记录, orderflag是排列顺序


下面是该页的代码:
<%
if request("method") = 1 then
classid = Qcdn.checkStr(Trim(Request.Form("classid")))
nclassid = Qcdn.checkStr(Trim(Request.Form("nclassid")))
title = Qcdn.checkStr(Trim(Request.Form("title")))
Content = Qcdn.checkStr(Trim(Request.Form("body")))
synopsis = Qcdn.checkStr(Trim(Request.Form("synopsis")))
Intime = Request("year1") & "-" & Request("month1") & "-" & Request("day1") & " " & request("hour1") & ":" & request("minute1") & ":" & request("second1")
if nclassid="" then
nclassid="0"
end if
isTop=request("isTop")
if trim(isTop)="" then isTop=0
if trim(request("DefaultPic"))="" then
smallphoto=""
else
smallphoto=request("DefaultPic")
end if
enorcn=request("enorcn")
if trim(request("DefaultPicB"))="" then
photo=""
else
photo=request("DefaultPicB")
end if
OrderFlag=request("OrderFlag")
if not isnumeric(OrderFlag) and Orderflag="" then
OrderFlag="0"
end if
isPoPuP=request("isPopup")
if isPopup<>"1" then isPopup="0"
PopupWidth=request("PopupWidth")
if not isnumeric(PopupWidth) then PopupWidth=0
if trim(PopupWidth)="" then PopupWidth=0
PopupHeight=request("PopupHeight")
if not isnumeric(PopupHeight) then PopupHeight=0
if trim(PopupHeight)="" then PopupHeight=0
Sql = "Insert into News "
sql=sql & "(classid,nclassid,title,Description,Intime,synopsis,IncFiles,isTop,smallphoto,enorcn,bigphoto,orderflag,popupwidth,popupheight,ispopup)"
sql=sql & " values(" & classid & "," & nclassid & ",'" & title & "','"
sql =sql & Content &"','"& Intime &"','" & synopsis & "','" & request("IncFiles") & "','" & isTop & "','" & smallphoto & "','" & enorcn & "','" & photo & "',"
sql=sql & orderflag & "," & popupwidth & "," & popupheight & "," & isPopup & ")"
Conn.execute(Sql)
Response.Write("<script>alert(""添加成功"");location.href=""admin_new.asp"";</script>")
Response.End()
end if
set rs = conn.execute("select unid,classname,flag from news_class where flag<>0 order by Unid asc")
if rs.eof then secoundY=false else secoundY=true
%>

<form action="" name="form1" method="post" onSubmit="WBTB_CopyData('Body');">
<tr>
<td colspan="2" align="center" height="30" background="image/tablebg.gif">
<b>新闻发布 </b> </td>
</tr>
<tr valign="middle">
<td width="14%" height="25">新闻类别: </td>
<td width="86%" height="25"> <%
set rs = conn.execute("select Unid,classname from News_class where flag = 0 order by enorcn,orderflag asc")
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%> <select name="classid"
<% if secoundY then %>
onChange="changelocation(document.form1.classid.options[document.form1.classid.selectedIndex].value)"
<% end if%>
>
<option value="">选择大类 </option>
<%do while not rs.eof%>
<option value=" <%=rs(0)%>"> <%=Qcdn.HTMLcode(rs(1))%> </option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select> <font color="red">
<% if secoundY then %>
<select name="Nclassid">
<option value="">选择小类 </option>
</select>
<% else %>

<input type="hidden" name="Nclassid" value="0">
<% end if %>
* </font> <input type="hidden" name="IncFiles" value=""> </td>
</tr>
babycry627 2009-07-22
  • 打赏
  • 举报
回复
学习下
tfzdh 2009-07-22
  • 打赏
  • 举报
回复
学习经验
银狐被占用 2009-07-22
  • 打赏
  • 举报
回复
表结构设计有问题。
用5楼的吧。
toury 2009-07-22
  • 打赏
  • 举报
回复
分类表结构错误。
unid classname flag flag2 orderflag
17 企业介绍 0 0 1 一级栏目
46 联系我们 0 0 8 一级栏目
65 产品中心 0 0 3 一级栏目
67 新闻中心 0 0 4 一级栏目
73 压滤机系列 65 0 1 二级栏目
75 离心机系列 65 0 1 二级栏目
94 监控设备 3 73 1 三级栏目
95 监控器材 3 73 1 三级栏目
既然“flag2是三级栏目的对应上一级的ID记录”,红字的数据怎么可能为0呢?flag为0的一级分类有4个,你怎么确定红字对应的分类属于那个上一级分类?
-----------------------
这样才可以 (classslevel--分类级别 parentID--所属上级分类ID)
unid classname calsslevel parentID orderflag
17 企业介绍 0 0 1 一级栏目
46 联系我们 0 0 8 一级栏目
65 产品中心 0 0 3 一级栏目
67 新闻中心 0 0 4 一级栏目
73 压滤机系列 2 65 1 二级栏目
75 离心机系列 2 65 2 二级栏目
94 监控设备 3 73 1 三级栏目
95 监控器材 3 73 2 三级栏目
mioho 2009-07-22
  • 打赏
  • 举报
回复
谢谢~~~明白了。
toury 2009-07-22
  • 打赏
  • 举报
回复

<!--#include file=conn.asp--><!--换成你的数据库连接文件-->
<%
dim class_1,class_2,class_3,rs
class_1=Request.Form("class_1")
if class_1="" then class_1=0
class_2=Request.Form("class_2")
if class_2="" then class_2=0
class_3=Request.Form("class_3")
if class_3="" then class_3=0

set rs=server.CreateObject("adodb.recordset")
%>
<table border=1>
<form action="换成你的页面.asp" name="form1" method="post">
<tr>
<td colspan="2" align="center" height="30" background="image/tablebg.gif">
<b>新闻发布 </b> </td>
</tr>
<tr valign="middle">
<td width="14%" height="25">新闻类别: </td>
<td width="86%" height="25">
<%
sql="SELECT * FROM News_class WHERE calsslevel=0 ORDER BY orderflag"
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
rs.close: set rs=nothing
conn.close: set conn=nothing
response.end
end if

with response
'一级分类选择框
.write("<select name='class_1' onchange='javascript:document.form1.submit();'>")
.write("<option value='0' selected>--请选择一级分类--</option>")
do while not rs.eof
if cint(class_1)=cint(rs(0)) then sel=" selected" else sel=""
.write("<option value='"&rs(0)&"'"&sel&">"&rs(1)&"</option>")
rs.movenext
loop
.Write("</select>")
end with
rs.close

if class_1>0 then'如果选择了一级框
sel=""
'二级分类选择框
sql="SELECT * FROM News_class WHERE calsslevel=1 AND parentID="&class_1&" ORDER BY orderflag"
rs.open sql,conn,1,1
if rs.eof then msg="请添加该栏目的二级分类" else msg="--请选择二级分类--"
with response
.write("<select name='class_2' onchange='javascript:document.form1.submit();'>")
.write("<option value='0' selected>"&msg&"</option>")
do while not rs.eof
if cint(class_2)=cint(rs(0)) then sel=" selected" else sel=""
.write("<option value='"&rs(0)&"'"&sel&">"&rs(1)&"</option>")
rs.movenext
loop
.Write("</select>")
end with
end if
rs.Close

if class_2>0 then'如果选择了二级框
sel=""
'三级分类选择框
sql="SELECT * FROM News_class WHERE calsslevel=2 AND parentID="&class_2&" ORDER BY orderflag"
rs.open sql,conn,1,1
if rs.eof then msg="请添加该栏目的三级分类" else msg="--请选择三级分类--"
with response
.write("<select name='class_3' onchange='javascript:document.form1.submit();'>")
.write("<option value='0' selected>"&msg&"</option>")
do while not rs.eof
if cint(class_3)=cint(rs(0)) then sel=" selected" else sel=""
.write("<option value='"&rs(0)&"'"&sel&">"&rs(1)&"</option>")
rs.movenext
loop
.Write("</select>")
end with
end if
rs.Close: set rs=nothing
conn.close: set conn=nothing
%>
</tr>
</table>
toury 2009-07-22
  • 打赏
  • 举报
回复
表结构及测试数据(在此基础上,你把你需要添加的字段加进去)
unid classname calsslevel parentID orderflag
1 企业介绍 0 0 1
2 联系我们 0 0 8
3 产品中心 0 0 3
4 新闻中心 0 0 4
5 压滤机系列 1 3 1
6 离心机系列 1 3 2
7 监控设备 2 5 1
8 监控器材 2 5 2
toury 2009-07-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 mioho 的回复:]
我的是一个表分三级的类别。。请问你有例子么?
[/Quote]
这个不难。你把你的联动规则以及分类表中的关联字段列出来
mioho 2009-07-21
  • 打赏
  • 举报
回复
我的是一个表分三级的类别。。请问你有例子么?
toury 2009-07-21
  • 打赏
  • 举报
回复
二级改三级关乎到你的数据库表的结构,如果是无限分类的结构是一种方式,如果加多一个三级分类的表又是另一种方式。

通常有ajax无刷新和点选父级SELECT后刷新页面填充次级SELECT两种途径。不知道你的情况是怎么样的

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧