惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 似水流年

html颜色代码对照表 - 似水流年 - 博客园 让jbuilder显示中文 mysql数据导入导出语句 如何去掉超链接的下划线 使用标记文件更新和查询数据库 用一个链接同时打开两个帧页 DisplayTag应用实践 Tomcat配置之自订tomcat Tag File简介 JS控制显示表单个数 让tomcat支持中文Url传递 JSP文件操作 用MYSQL中的加密函数来加密:PASSWORD() 转义字符\的替换 - 似水流年 - 博客园 jsp中取得当前绝对路径的方法 Jstl申明DateSource Jstl验证用户登录 jstl验证用户是否已登录 在调用删除页面是出现提示信息
Jsp+javascript打造二级级联下拉菜单
似水流年 · 2005-03-21 · via 博客园 - 似水流年

数据库需求分析:
class(一级栏目信息):classId(自动编号),className(栏目名称)
Nclass(二级栏目信息):NclassId(自动编号),NclassName(栏目名称),parentId(一级栏目id,与class表中的classId关联)

<%@ page contentType="text/html; charset=GB2312" language="java" errorPage="../error.jsp" %>
<%@ include file="../conn.jsp"%>
<%@ include file="../ds.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%request.setCharacterEncoding("gb2312"); %>
<HTML><HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">

<TITLE>级联菜单</TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
</HEAD>
<!--从数据库中得到二级栏目信息-->
<%String sql="select * from Nclass order by NclassId asc";
ResultSet rs=stmt.executeQuery(sql);
%>
<!--将二级栏目信息保存到数组subcat中-->
<script type="text/javascript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        int count = 0;
        while(rs.next()){
        %>
subcat[<%=count%>] = new Array("<%=rs.getString("NclassName")%>","<%=rs.getString("NclassId")%>","<%=rs.getString("parentId")%>");
        <%
        count++;
        }
        rs.close();
        %>
onecount=<%=count%>;
<!--决定select显示的函数-->
function changelocation(locationid)
    {
    document.myform.NclassId.length = 0;

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][2] == locationid)
            {
                document.myform.NclassId.options[document.myform.NclassId.length] = new Option(subcat[i][0], subcat[i][1]);
            }       
        }
       
    }   
</script>

<FORM method="POST" name="myform" action="adminsave.jsp?action=add">
  <TABLE>
  
    <TR>
      <TD>一级分类</TD>
      <TD> 
        <SELECT name="classId" onChange="changelocation(document.myform.classId.options[document.myform.classId.selectedIndex].value)" size="1">
          <OPTION selected value>==请选一级分类==</OPTION>
        <sql:query var="query" dataSource="${bookdev}">
          SELECT * FROM class
       </sql:query>
<c:forEach var="row" items="${query.rows}">
 <option value="${row.classId}">${row.className}</option>
</c:forEach>
</select>
      </TD>
      <TD>选择二级分类</TD>
      <TD>
        <SELECT name="NclassId">
          <OPTION selected value>==请选二级分类==</OPTION>
        </SELECT>
      </TD>
    </TR>
</TABLE>
 
</FORM>
</BODY>
</HTML>