Jsp+javascript to create a cascade menu of instance code _javascript skills

Source: Internet
Author: User
Tags stmt

Copy Code code as follows:

<%@ page import= "java.util.date,yava.fileapp.*,java.sql.*;"
Contenttype= "text/html;charset=gb2312" pageencoding= "GB2312"
%>
<style>
. f9{font-size:9pt;}
. bgc{background-color: #AECAF9; color: #0033FF}
Buttons{font-family:arial font-size:13px; Font-weight:bold background-color: #6796E4; color:white; Border-top: Solid 2px #AACAFB;
Border-bottom:solid 1px #4E7DC1;
Border-left:solid 1px #AECAF9;
Border-right:solid 1px #5679BD;
padding:1px;
margin:0px;}
</style>
<script language= "JavaScript" >
<!--
Function RV ()
{
var val= "";
for (i=0;i<combo_box.list2.length;i++) {
val+= "," +combo_box.list2[i].value;
}
if (Val.charat (0) = = ",") {
Val=val.substr (1,val.length);
}
Opener.form1.frecname.value=val;
Self.close ();
}

-->
</SCRIPT>
<body leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >
<JSP (Preferred for Sun enterprise applications): Usebean id= "User" scope= "session" class= "Yava.fileapp.UserBean"/>
<%
CDataSource ds=new CDataSource (); Data Connection Bean Instance
Java.sql.Connection conn=ds.getconnection ();
Java.sql.Statement Stmt=null;
Java.sql.ResultSet Rs=null;
Cdatacheck dc=new Cdatacheck ();
%>

<%
String sqlu= "Select T1.fno, T1.fname, t2.fname as fdept from Tuser T1 left OUTER JOIN tdept t2 in t1.fdept = t2.fno order by T2.fname ";
Stmt=conn.createstatement ();
Rs=stmt.executequery (SQLU);
%>
<script language=javascript>
arr = new Array ();
<% int temp=0;
while (Rs.next ())
{
%>
Arr[<%=temp%>]=new Array ("<%=rs.getstring" ("fname")%> "," <%=rs.getstring ("fdept")%> ");
<%
temp = temp + 1;
}
%>
temp=<%=temp%>;
function changelocation (ID) {
document.combo_box.city.length=0; Initializes the length of level 2nd menus, starting with the subscript 0
var i = 0;
Document.combo_box.city.options[0]=new Option (-------,);
for (i=0;i<temp;i++) {
if (arr[i][1]==id) {//if equal, it is shown that there is a subset of input level 1th organization in level 2nd, total number of arr[[department]
Document.combo_box.city.options[document.combo_box.city.length] = new Option (arr[i][0], arr[i][0]);
}
}
}
</script>

<form name= "Combo_box" >
<table border= "0" cellspacing= "0" cellpadding= "0" height= "210" width= ">"
<tr height= ">"
<TD bgcolor= "#336699" class= "buttons" Align=center><font color= #ffffff > Department Selection </font></td>
<TD bgcolor= "#336699" class= "buttons" Align=center><font color= #ffffff > Name Selection </font></td>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.