jsp+javascript打造级连菜单
<%@ page import="java.util.date,yava.fileapp.*,java.sql.*;"5y NY:d'@p/@c pageencoding="gb2312"x!N[`,fz
%>
<style>4qZDs;ye/\&G,C
.f9{ font-size:9pt; }I;KO$aLI$g;kB F
.bgc{ background-color:#aecaf9; color: #0033ff }S(k5sR/` x1R[T
.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;sSP~ y:bqZw
border-right: solid 1px #5679bd;
padding:1px;
margin:0px;}T$v6r1B%N#o%a
</style>
<script language="javascript">Y y"?^F0or _
<!--
function rv()8D vd sy6CS-N
{
var val="";
for(i=0;i<combo_box.list2.length;i++){Gg)KhN2xp;e
val+=","+combo_box.list2[i].value;
}
if(val.charat(0)==","){
val=val.substr(1,val.length);
}q0VeHw5toZY5io$S
opener.form1.frecname.value=val;
self.close();hH8h4m4G0T{DJ
}H/aG$v(R
//-->(r$J\6IKOP
</script>(dR4vqt
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<jsp:usebean id="user" scope="session" class="yava.fileapp.userbean" />S#I1\0?)o
<%
cdatasource ds=new cdatasource(); //数据联结bean实例y_)hJry xaS
java.sql.connection conn=ds.getconnection();SJArxq
java.sql.statement stmt=null;
java.sql.resultset rs=null;
cdatacheck dc=new cdatacheck();B+Uy+so
%>,F%v K B!u%^ DY;U c
<%+h+B9k Vu8V
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";C wU-rGP,ow
stmt=conn.createstatement();|_v TGw9n v W
rs=stmt.executequery(sqlu);c4bG2tS| o+P(qK
%>6XR5c(I3?I:xA.gG_?
<script language='javascript'>xS*Cmp
arr = new array();
<% int temp=0;
while(rs.next())"T8af?3A;X
{,F aY;G@4K]
%> a.T0ZVco
arr[<%=temp%>]=new array("<%=rs.getstring("fname")%>","<%=rs.getstring("fdept")%>");
<%
temp = temp + 1;
}v5hNIqOH9Uu0y
%>
temp=<%=temp%>;rz/mVS/kP.t
function changelocation(id){
document.combo_box.city.length=0; //初始化第2级菜单的长度,下标从0开始 3qQ[4f5c ?2OX9tG
var i = 0;
document.combo_box.city.options[0]=new option('-------',''); 7I5g3_S _
for(i=0;i<temp;i++){ @A T`~2|/G8K5m
if(arr[i][1]==id){//如果相等,证明在第2级里面有输入第1级组织的子集,arr[总数目][部门] cW d`+nwQ
document.combo_box.city.options[document.combo_box.city.length] = new option(arr[i][0], arr[i][0]); aJ(l"Q,N[O j
} 4Li;d9r!m6R7CYN#cGk
} )| uJ!`"q-MR
} (s+z Q,X(u+_-L4g~
</script>]8D$R2qUak:X0e
<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>0V+SEQGZ;l8w
<td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>人名选择</font></td>4s'RC'Q3~ [(hC
<td bgcolor="#336699" class="buttons" align=center nowrap><font color=#ffffff>添加/移除</font></td>
<td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>最终人</font></td>M1E,?p,w*a7_
</tr>7c6X"I1M-XSNV
<tr>
<td>#LK~6U#Fx o
<select multiple id=prov name="prov" style="width:150;height:200" class="bgc">H:S/o3P5B5L&x1gf
<option value="0">请选择部门 ---></option>
<%
string sqld="select * from tdept";
stmt=conn.createstatement();B1tkn I j
rs=stmt.executequery(sqld);
while(rs.next()))q Kk9[f;Z A3HZ
{
%>0A1qre| m;S
<option name="<%=rs.getstring("fno")%>"><%=rs.getstring("fname")%></option>
<%M^6qa\Tt
}
%> 2Bi4{7o*\a8W
</select>
</td>9j,j(HL4i}P
<td>"K!@U6}f(];Y
<select multiple id=city style="width:150;height:200" class="bgc">+C0pw5M#B5T*}o8U
</select>3f:q c"{A-SHT
</td>/Z2N"t(?Nzc7fF
<td nowrap align="center" class="bgc">tM0s\5lE,J
<input type="button" value="<<" class="buttons">.K2r k2~F5_)@ J
<input type="button" value=">>" class="buttons">,E p|$Ze-y?!c
</td>R C0R"n"j#?
<td>Z2b$@ S@:q
<select multiple size="10" name="list2" style="width:150;height:200" class="bgc">
</select>S"Jg|H%D'~(Oq
</td>7I:ur+@BW4KK
</tr>
<tr class="bgc"> `J^L4mXs {8A
<td colspan="4" align="center"><input type="button" name="button1" class="buttons" value="选好了!" ></td>^Jj0Z8qo*H
</tr>
</table>
</form>7Q*L9F%G$H
<script language="javascript">9J/H)W#}}X
//人名移动,e1nWWb,q0? CG
function move(fbox, tbox) {n a3N;POQ3y
var arrfbox = new array();rQi3^-u7T@?
var arrtbox = new array();5g*}&|!f%Fq
var arrlookup = new array(); J2hejn;i
var i;Q!d_N"Xe7rY?
for (i = 0; i < tbox.options.length; i++) {