asp 联动菜单 从数据库读取 5
<selectname="biglocation"onChange="changelocation(document.myform.biglocation.options...
<select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)" size="1">
<option selected>请选择所属类别</option>
<%
Set rs1 = Server.CreateObject("ADODB.Recordset")
sql1 = "select * from hddnc_productstype_one order by productstype_one_id asc"
rs1.open sql1,conn,1,1
do while not rs1.eof
%>
%>
<option <%if trim(rs1("productstype_one_id"))=biglocation then%>selected<%end if%> value="<%=trim(rs1("productstype_one_id"))%>"><%=trim(rs1("productstype_one_one"))%></option>
<%
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.Close
set conn = nothing
%>
</select>
这个是一级联动代码我想知道 IF 语句发现已选择一级菜单 默认会选中,但是二级菜单不加载
如何执行 onChange 的脚本 展开
<option selected>请选择所属类别</option>
<%
Set rs1 = Server.CreateObject("ADODB.Recordset")
sql1 = "select * from hddnc_productstype_one order by productstype_one_id asc"
rs1.open sql1,conn,1,1
do while not rs1.eof
%>
%>
<option <%if trim(rs1("productstype_one_id"))=biglocation then%>selected<%end if%> value="<%=trim(rs1("productstype_one_id"))%>"><%=trim(rs1("productstype_one_one"))%></option>
<%
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.Close
set conn = nothing
%>
</select>
这个是一级联动代码我想知道 IF 语句发现已选择一级菜单 默认会选中,但是二级菜单不加载
如何执行 onChange 的脚本 展开
1个回答
展开全部
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>敏橘","<%= trim(rs("SmallClassName"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.addNEWS.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<%
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%><select name="BigClassName" onChange="changelocation(document.addNEWS.BigClassName.options[document.addNEWS.BigClassName.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
dim selclass
selclass=rs("BigClassName")
rs.movenext
do while not rs.eof
%>
<option value="<桥渣团%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> <select name="SmallClassName">
<%
sql="select * from SmallClass where BigClassName='" & selclass & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=rs("SmallClassName")%>">不指定</option>
<% rs.movenext
do while not rs.eof%>
<option value="梁姿<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>敏橘","<%= trim(rs("SmallClassName"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.addNEWS.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<%
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%><select name="BigClassName" onChange="changelocation(document.addNEWS.BigClassName.options[document.addNEWS.BigClassName.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
dim selclass
selclass=rs("BigClassName")
rs.movenext
do while not rs.eof
%>
<option value="<桥渣团%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> <select name="SmallClassName">
<%
sql="select * from SmallClass where BigClassName='" & selclass & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=rs("SmallClassName")%>">不指定</option>
<% rs.movenext
do while not rs.eof%>
<option value="梁姿<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询