| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 997 人关注过本帖
标题:[求助]请问二级下拉菜单导航如何读取数据库中分类啊?
只看楼主 加入收藏
xiaozhou2008
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-2-9
收藏
 问题点数:0 回复次数:1 
[求助]请问二级下拉菜单导航如何读取数据库中分类啊?
普通的导航菜单都只能读取固定的链接,我有2个表,bigclass和smallclass,请问如何制作二级下拉菜单,让菜单中读取数据库中的大类和小类啊?哪位大虾给段代码,谢谢了!!!!
搜索更多相关主题的帖子: 数据库 菜单 导航 分类 
2008-02-09 14:55
21411
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2008-1-10
收藏
得分:0 
<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]);
            }        
        }
    }   

function CheckForm()
{
     document. = document.(true);     
     document.addNEWS.imageNum.value = document.("editImageNum").value;
     document.addNEWS.editFirstImageName.value = document.("editFirstImageName").value;

    if (document.addNEWS.title.value.length == 0) {
        alert("文章标题没有填写.");
        document.addNEWS.title.focus();
        return false;
    }
        if (document.addNEWS.user.value.length == 0) {
        alert("文章发布人没有填写");
        document.addNEWS.user.focus();
        return false;
    }
    return true;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css.css" type="text/css">
<title>添加文章</title>
<style type="text/css">
<!--
body {
    background-color: #ECE9D8;
}
.style1 {
    color: #FFFFFF;
    font-weight: bold;
}
-->
</style></head>

<body leftmargin="0" topmargin="0" bgcolor="#ECE9D8">
<br>
<table width="65%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#245DDB">
  <form name="addNEWS" method="post" action="addinfo_ok.asp" onSubmit="return CheckForm();">
    <tr bgcolor="#FFFFFF">
      <td height="25" bgcolor="#245DDB"><div align="center" class="style1">文章添加</div></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">
        <font color="#245DDB">*</font>文章标题:<input name="title" type="text" class="input" size="30"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">
        <font color="#245DDB">*</font>文章类别:<%
        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">
          <option value="" selected>不指定小类</option>
          <%
            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")%>"><%=rs("SmallClassName")%></option>
          <% rs.movenext
                do while not rs.eof%>
          <option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
          <%
                    rs.movenext
                loop
            end if
            rs.close
            %>
          <%
            ranNum=int(9*rnd)+10
            iddata=month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
            %>
      </select></td>
    </tr>
2008-02-10 22:15
快速回复:[求助]请问二级下拉菜单导航如何读取数据库中分类啊?
数据加载中...
 
   



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

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