多级分类?(100分)

蓝魂

Unregistered / Unconfirmed
GUEST, unregistred user!
两张表:
表1是类别:lb
字段:
id
isfather 父类标志
canadd 子类标志
grandadd 次子类标志
fatherid 父类ID
canaddid 子类ID
表2 product
字段
id
cpdlbid 产品大类别ID
cpxlbid 产品小类别ID
cpxxlbid 产品次类别ID
mc 产品名称
现在要先从表1中选出各类别,分别是父类,如果有子类则显示子类,如果有次类则次
类也显示;然后从表2中选出相应的的产品名称.
从表1中选 类别我的代码是:
ONLINE CATALOGUE
/ </b></font><select id="fathertypeid" name="fathertypeid" onchange="gosearch(this)">
<% dim objConn,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorType=adOpenStatic
objRS.CursorLocation=aduseclient
Set objRS.ActiveConnection = objConn
strsql="select * from lb where isfather=true order by flow,id desc"
objRS.Open strsql
firstfatherid=0
do while not(objRS.EOF)
if CInt(fathertypeid)=objRS("id") then
response.write("<option value='"&amp;objRS("id")&amp;"' selected>"&amp;objRS("name")&amp;"</option>")
else
response.write("<option value='"&amp;objRS("id")&amp;"'>"&amp;objRS("name")&amp;"</option>")
end if
if firstfatherid=0 then
firstfatherid=objRS("id")
objRS.MoveNext
loop
objRS.Close
%>
</select>
<%If fathertypeid<>"" then
strsql="select * from lb where id="&amp;CInt(fathertypeid)
objRS.Open strsql
if not objRS.Eof then
if objRS("CanAdd") then

objRS.Close
%>
<font color="#000000"><b> / </b></font>
<select id="sontypeid" name="sontypeid" onchange="gosearch1(this)">
<%
strsql="select * from lb where canaddid=0 and fatherid="&amp;CInt(fathertypeid)
objRS.Open strsql
if not objRS.eof then
firstsonid=0
do while not objRS.eof
if CInt(sontypeid)=objRS("id") or firstsonid=0 then
response.write("<option value='"&amp;objRS("id")&amp;"' selected>"&amp;objRS("name")&amp;"</option>")
else
response.write("<option value='"&amp;objRS("id")&amp;"'>"&amp;objRS("name")&amp;"</option>")
end if
if firstsonid=0 then
firstsonid=objRS("id")
objRS.MoveNext
loop
end if
objRS.Close
%>
</select>
<%If sontypeid<>"" then
strsql="select * from lb where id="&amp;CInt(sontypeid)
objRS.Open strsql
if not objRS.Eof then
if objRS("grandAdd") then

objRS.Close
%>
<font color="#000000"><b> / </b></font>
<select id="grandtypeid" name="grandtypeid" onchange="gosearch2(this)" >
<%
strsql="select * from lb where canaddid="&amp;CInt(sontypeid)
objRS.Open strsql
if not objRS.eof then
firstgrandid=0
do while not objRS.eof
if CInt(grandtypeid)=objRS("id") or firstgrandid=0 then
response.write("<option value='"&amp;objRS("id")&amp;"' selected>"&amp;objRS("name")&amp;"</option>")
else
response.write("<option value='"&amp;objRS("id")&amp;"'>"&amp;objRS("name")&amp;"</option>")
end if
if firstgrandid=0 then
firstgrandid=objRS("id")
objRS.MoveNext
loop
end if
end if
objRS.Close
set objRS= Nothing
%>
</select>
<%end if
end if
end if
end if
end if
%>
结果只能选则父类下拉框显示子类,如果子类还有次类则只能再次选子类还会显示次类的下拉框,是怎么回事?
我想要达到的是:选一下父类,如果有相应的子类/次类都要显示,如果没有不显示.
 

Similar threads

顶部