ASP后台中如何调用产品类别代码(大类ID=anclassid 大类名称=anclass;小类ID=nclassid 小类名称=nclass)
<tdwidth="15%"align="right"class=tdbg>选择商品的分类:</td><tdwidth="85%"height="28"align="le...
<td width="15%" align="right" class=tdbg>选择商品的分类:</td>
<td width="85%" height="28" align="left" class=tdbg>
<p>大类:
<%dim rs1
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from products where bookid="&bookid,conn,1,1
rs.open "select * from bsort order by anclassidorder",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="anclassid" size="1" id="anclassid" onChange="changelocation(document.myform.anclassid.options[document.myform.anclassid.selectedIndex].value)">
<%
do while not rs.eof
%>
<option value="<%=rs("anclassid")%>" <%if rs1("anclassid")=rs("anclassid") then%>selected<%end if%>><%=trim(rs("anclass"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
小类:
<select name="Nclassid" id="Nclassid" onChange="changelocation1(document.myform.Nclassid.options[document.myform.Nclassid.selectedIndex].value)">
<%rs.open "select * from ssort where anclassid="&rs1("anclassid") ,conn,1,1
dim selclassid
selclassid=rs("nclassid")
do while not rs.eof%>
<option value="<%=rs("NclassID")%>" <%if rs1("nclassid")=rs("nclassid") then%>selected<%end if%>><%=rs("Nclass")%></option>
<% rs.movenext
loop
rs.close
set rs = nothing
%>
</select>
品牌:
<select name="pinpaiid">
<%
set rsa=server.createobject("adodb.recordset")
rsa.open "select * from pinpai where nclassid="&rs1("nclassid") ,conn,1,1
if not(rsa.eof and rsa.bof) then
do while not rsa.eof%>
<option value="<%=rsa("pinpaiid")%>" <%if rs1("pinpaiid")=rsa("pinpaiid") then%>selected<%end if%>><%=rsa("Nclass")%></option>
<% rsa.movenext
loop
end if
rsa.close
set rsa = nothing
%>
</select> </p></td>
产品名称是这样的调用的:
<td width="266" STYLE='PADDING-LEFT: 10px'class=tdbg> <a href=editproducts.asp?id=<%=rs("bookid")%>>
<% if len(trim(rs("bookname")))>20 then
response.write left(trim(rs("bookname")),18)&".."
else
response.write trim(rs("bookname"))
end if%>
</a></td>
请高手协一下,谢谢 展开
<td width="85%" height="28" align="left" class=tdbg>
<p>大类:
<%dim rs1
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from products where bookid="&bookid,conn,1,1
rs.open "select * from bsort order by anclassidorder",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="anclassid" size="1" id="anclassid" onChange="changelocation(document.myform.anclassid.options[document.myform.anclassid.selectedIndex].value)">
<%
do while not rs.eof
%>
<option value="<%=rs("anclassid")%>" <%if rs1("anclassid")=rs("anclassid") then%>selected<%end if%>><%=trim(rs("anclass"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
小类:
<select name="Nclassid" id="Nclassid" onChange="changelocation1(document.myform.Nclassid.options[document.myform.Nclassid.selectedIndex].value)">
<%rs.open "select * from ssort where anclassid="&rs1("anclassid") ,conn,1,1
dim selclassid
selclassid=rs("nclassid")
do while not rs.eof%>
<option value="<%=rs("NclassID")%>" <%if rs1("nclassid")=rs("nclassid") then%>selected<%end if%>><%=rs("Nclass")%></option>
<% rs.movenext
loop
rs.close
set rs = nothing
%>
</select>
品牌:
<select name="pinpaiid">
<%
set rsa=server.createobject("adodb.recordset")
rsa.open "select * from pinpai where nclassid="&rs1("nclassid") ,conn,1,1
if not(rsa.eof and rsa.bof) then
do while not rsa.eof%>
<option value="<%=rsa("pinpaiid")%>" <%if rs1("pinpaiid")=rsa("pinpaiid") then%>selected<%end if%>><%=rsa("Nclass")%></option>
<% rsa.movenext
loop
end if
rsa.close
set rsa = nothing
%>
</select> </p></td>
产品名称是这样的调用的:
<td width="266" STYLE='PADDING-LEFT: 10px'class=tdbg> <a href=editproducts.asp?id=<%=rs("bookid")%>>
<% if len(trim(rs("bookname")))>20 then
response.write left(trim(rs("bookname")),18)&".."
else
response.write trim(rs("bookname"))
end if%>
</a></td>
请高手协一下,谢谢 展开
2个回答
展开全部
changelocation 函数有没有呢?如果没有请加上:
<%dim counts
set rs=server.createobject("adodb.recordset")
rs.open "select * from ssort ",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
counts = 0
do while not rs.eof
%>
subcat[<%=counts%>] = new Array("<%= trim(rs("Nclass"))%>","<%= rs("anclassid")%>","<%= rs("Nclassid")%>");
<%
counts = counts + 1
rs.movenext
loop
rs.close
%>
onecount=<%=counts%>;function changelocation(locationid)
{
document.myform.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script >
同时去掉小类里的:
onChange="changelocation1(document.myform.Nclassid.options[document.myform.Nclassid.selectedIndex].value)"
<%dim counts
set rs=server.createobject("adodb.recordset")
rs.open "select * from ssort ",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
counts = 0
do while not rs.eof
%>
subcat[<%=counts%>] = new Array("<%= trim(rs("Nclass"))%>","<%= rs("anclassid")%>","<%= rs("Nclassid")%>");
<%
counts = counts + 1
rs.movenext
loop
rs.close
%>
onecount=<%=counts%>;function changelocation(locationid)
{
document.myform.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script >
同时去掉小类里的:
onChange="changelocation1(document.myform.Nclassid.options[document.myform.Nclassid.selectedIndex].value)"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询