茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    用JSP+JavaScript打造二級級聯(lián)下拉菜單
    來源:易賢網 閱讀:1796 次 日期:2015-01-27 14:41:02
    溫馨提示:易賢網小編為您整理了“用JSP+JavaScript打造二級級聯(lián)下拉菜單”,方便廣大網友查閱!

    class(一級欄目信息):classId(自動編號),className(欄目名稱), Nclass(二級欄目信息), NclassId(自動編號),NclassName(欄目名稱),parentId(一級欄目id,與class表中的classId關聯(lián))<%@ 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 divfix=sql %>

    <%request.setCharacterEncoding(gb2312); %>

    <HTML><HEAD>

    <META http-equiv=Content-Type content=text/html; charset=gb2312>

    <TITLE>級聯(lián)菜單</TITLE>

    <LINK rel=stylesheet type=text/css href=style.css>

    </HEAD>

    <!--從數(shù)據(jù)庫中得到二級欄目信息-->

    <%String sql=select * from Nclass order by NclassId asc;

    ResultSet rs=stmt.executeQuery(sql);

    %>

    <!--將二級欄目信息保存到數(shù)組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顯示的函數(shù)-->

    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=$>

    SELECT * FROM class

    </sql:query>

    <c:forEach var=row items=$>

    <option value=$>$</option>

    </c:forEach>

    </select>

    </TD>

    <TD>選擇二級分類</TD>

    <TD>

    <SELECT name=NclassId>

    <OPTION selected value>==請選二級分類==</OPTION>

    </SELECT>

    </TD>

    </TR>

    </TABLE>

    </FORM>

    </BODY>

    </HTML>

    <%@ 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 divfix=sql %>

    <%request.setCharacterEncoding(gb2312); %>

    <HTML><HEAD>

    <META http-equiv=Content-Type content=text/html; charset=gb2312>

    <TITLE>級聯(lián)菜單</TITLE>

    <LINK rel=stylesheet type=text/css href=style.css>

    </HEAD>

    <!--從數(shù)據(jù)庫中得到二級欄目信息-->

    <%String sql=select * from Nclass order by NclassId asc;

    ResultSet rs=stmt.executeQuery(sql);

    %>

    <!--將二級欄目信息保存到數(shù)組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顯示的函數(shù)-->

    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=$>

    SELECT * FROM class

    </sql:query>

    <c:forEach var=row items=$>

    <option value=$>$</option>

    </c:forEach>

    </select>

    </TD>

    <TD>選擇二級分類</TD>

    <TD>

    <SELECT name=NclassId>

    <OPTION selected value>==請選二級分類==</OPTION>

    </SELECT>

    </TD>

    </TR>

    </TABLE>

    </FORM>

    </BODY>

    </HTML>

    更多信息請查看IT技術專欄

    更多信息請查看腳本欄目

    2026上岸·考公考編培訓報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網