| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 683 人关注过本帖
标题:三级联动问题
只看楼主 加入收藏
jendy5566
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2010-3-18
结帖率:54.55%
收藏
已结贴  问题点数:50 回复次数:2 
三级联动问题
想做一个三级联动的菜单,但是只实现了一个,第二个没有起作用,找不到原因,在此麻烦各位大神帮看看,错在哪里。谢谢了!提示错误是:‘document.addNEWS.SsclassName‘为空或不是对象。
程序代码:
<%
dim rs
dim rs2
dim rs3
dim sql
dim sql2
dim sql3
dim count
dim count2
set rs=server.createobject("adodb.recordset")
sql = "select * from SmallClass where SmallClassID order by SmallClassID asc"
rs.open sql,conn,1,1
set rs2=server.createobject("adodb.recordset")
sql2="select * from ssclass order by ssid asc"
rs2.open sql2,conn,1,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]);
            }       
        }
    }   
var onecount2;
subcat2=new Array();
    <%
    count2=0
    do while not rs2.eof
    %>
subcat2[<%=count2%>]=new Array("<%= trim(rs2("SscalssName"))%>","<%= trim(rs2("SmallClassName"))%>","<%= trim(rs2("SscalssName"))%>");
<%
        count2 = count2 + 1
        rs2.movenext
        loop
        rs2.close
        %>
        onecount2=<%=count2%>;
function changelocation2(locationid2)
    {
    document.addNEWS.SsClassName.length=1;
    var locationid2=locationid2;
    var j;
    for(j=0;j<onecount;j++)
    {
    if(subcat[j][1]==locationid2)
        {
        document.addNEWS.SsclassName.options[document.addNEWS.SsclassName.length] = new Option(subcat2[j][0], subcat2[j][2]);
        }
    }
    }

</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../include/css.css" type="text/css">
<title>添加文章</title>
</head>

<body leftmargin="0" topmargin="0" bgcolor="#FFFFEE">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
  <form name="addNEWS" method="post" action="addinfo_ok.asp" onSubmit="return CheckForm();">
    <tr>
      <td height="25"><font color="#FF0000">*</font>新闻类别:</td>
      <td colspan="2">
        <%
        sql = "select * from BigClass where urlok=0 and  bigclassid in ("&session("strbigidtype")&")"
        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>
          <%
        sql2 = "select * from SmallClass where BigClassName='" & selclass & "'"
        rs2.open sql2,conn,1,1
        if rs2.eof and rs2.bof then
            response.write "请先添加二级栏目。"
        else
        %>
        <select name="SmallClassName" onChange="changelocation2(document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.selectedIndex].value)">
        <option value="" selected>***请指定二级分类***</option><option selected value="<%=trim(rs2("SmallClassName"))%>"><%=trim(rs2("SmallClassName"))%></option>
         <%
            dim selclass2
            selclass2=rs2("SmallClassName")
            rs2.movenext
            do while not rs2.eof
            %>
          <option value="<%=trim(rs2("SmallClassName"))%>"><%=trim(rs2("SmallClassName"))%></option>
          <%
                rs2.movenext
            loop
        end if
        rs2.close
            %>
        </select>
        <%response.Write(selclass2)%>
        <%
        Set rs3 = Server.CreateObject("ADODB.Recordset")
        sql3 = "select * from ssclass where SmallClassName='" & selclass2 & "'"
        rs3.open sql3,conn,1,1
        if rs3.eof and rs3.bof then
            response.write "请先添加三级栏目。"
        else
        %>
        <select name="SscalssName"><option value="" selected>请指定三级分类</option>
        <option selected value="<%=trim(rs3("SscalssName"))%>"><%=trim(rs3("SscalssName"))%></option>
         <%
            dim selclass3
            selclass3=rs3("SmallClassName")
            rs3.movenext
            do while not rs3.eof
            %>
          <option value="<%=trim(rs3("SscalssName"))%>"><%=trim(rs3("SscalssName"))%></option>
          <%
                rs3.movenext
            loop
        end if
        rs3.close
            %>
        </select>        </td>
    </tr>
       
</table>
</body>
</html>
2014-01-15 00:03
jendy5566
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2010-3-18
收藏
得分:0 
还没有人来。。。。。
2014-01-15 15:52
hugeannex
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:6
帖 子:483
专家分:911
注 册:2005-3-20
收藏
得分:35 
好古老的代码,兼容性又差。
还有,这论坛已经没人气了。今非昔比。以后我也少来了。

世事如潮我如水,只叹江湖几人回。
2014-01-16 11:02
快速回复:三级联动问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033962 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved