jsp+javascript打造級連菜單的執行個體代碼

來源:互聯網
上載者:User

複製代碼 代碼如下: <%@ 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(SUN企業級應用的首選):useBean id="user" scope="session" class="yava.fileapp.UserBean" />
<%
CDataSource ds=new CDataSource(); //資料連接Bean執行個體
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 ON 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; //初始化第2級菜單的長度,下標從0開始
var i = 0;
document.combo_box.city.options[0]=new Option(-------,);
for(i=0;i<temp;i++){
if(arr[i][1]==id){//如果相等,證明在第2級裡面有輸入第1級組織的子集,arr[總數目][部門]
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="59">
<tr height="24">
<td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>部門選擇</font></td>
<td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>人名選擇</font></td>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.