javascript|js| Menu | dropdown
Database Requirements Analysis:
Class (First-level column information): classId (Automatic numbering), className (column name)
NClass (Level two column information): NCLASSID (Automatic numbering), nclassname (column name), ParentID (First level column ID, and the class table in the ClassID Association)
<%@ 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> cascading Menu </TITLE>
<link rel= "stylesheet" type= "Text/css" href= "Style.css" >
</HEAD>
<!--get two-level column information from the database-->
<%string sql= "SELECT * from NClass ORDER by nclassid ASC";
ResultSet rs=stmt.executequery (SQL);
%>
<!--to save the level two column information to the array 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%>;
<!--determine the function--> the Select display
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> First Class </TD>
<TD>
<select name= "ClassId" size= "1" >
<option selected value>== Please select one level of classification ==</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> Select Class Two </TD>
<TD>
<select name= "Nclassid" >
<option Selected value>== Please select Class Two classification ==</option>
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>