<% @ 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: 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 ON t1.fdept = t2.fno order by t2.fname ";
Stmt = conn. createStatement ();
Rs1_stmt.exe cuteQuery (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; // initialize the length of the 2nd-level menu. The subscript starts from 0.
Var I = 0;
Document. combo_box.city.options [0] = new Option (-------,);
For (I = 0; I <temp; I ++ ){
If (arr [I] [1] = id) {// if they are equal, it is proved that there is a subset of the 2nd-level organization input in level 1st, and arr [total number] [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 = "59">
<Tr height = "24">
<Td bgcolor = "#336699" class = "buttons" align = center> <font color = # ffffff> select a department </font> </td>
<Td bgcolor = "#336699" class = "buttons" align = center> <font color = # ffffff> name selection </font> </td>
<Td bgcolor = "#336699" class = "buttons" align = center nowrap> <font color = # ffffff> Add/Remove </font> </td>
<Td bgcolor = "#336699" class = "buttons" align = center> <font color = # ffffff> final person </font> </td>
</Tr>
<Tr>
<Td>
<Select multiple id = prov name = "prov" onchange = "ChangeLocation (combo_box.prov.options [combo_box.prov.selectedIndex]. text); "style =" width: 150; height: 200 "class =" bgc ">
<Option value = "0"> select a department ---> </option>
<%
String sqld = "SELECT * FROM tdept ";
Stmt = conn. createStatement ();
Rs1_stmt.exe cuteQuery (sqld );
While (rs. next ())
{
%>
<Option name = "<% = rs. getString (" fno ") %>"> <% = rs. getString ("fname") %> </option>
<%
}
%>
</Select>
</Td>
<Td>
<Select multiple id = city style = "width: 150; height: 200" class = "bgc">
</Select>
</Td>
<Td nowrap align = "center" class = "bgc">
<Input type = "button" onClick = "move (this. form. list2, this. form. city)" value = "<" class = "buttons">
<Input type = "button" onClick = "move (this. form. city, this. form. list2)" value = ">" class = "buttons">
</Td>
<Td>
<Select multiple size = "10" name = "list2" style = "width: 150; height: 200" class = "bgc">
</Select>
</Td>
</Tr>
<Tr class = "bgc">
<Td colspan = "4" align = "center"> <input type = "button" name = "button1" class = "buttons" value = "selected! "Onclick =" rv (); "> </td>
</Tr>
</Table>
</Form>
<Script language = "JavaScript">
// Move a person's name
Function move (fbox, tbox ){
Var arrFbox = new Array ();
Var arrTbox = new Array ();
Var arrLookup = new Array ();
Var I;
For (I = 0; I <tbox. options. length; I ++ ){
ArrLookup [tbox. options [I]. text] = tbox. options [I]. value;
ArrTbox [I] = tbox. options [I]. text;
}
Var fLength = 0;
Var tLength = arrTbox. length;
For (I = 0; I <fbox. options. length; I ++ ){
ArrLookup [fbox. options [I]. text] = fbox. options [I]. value;
If (fbox. options [I]. selected & fbox. options [I]. value! = ""){
ArrTbox [tLength] = fbox. options [I]. text;
TLength ++;
}
Else {
ArrFbox [fLength] = fbox. options [I]. text;
FLength ++;
}
}
ArrFbox. sort ();
ArrTbox. sort ();
Fbox. length = 0;
Tbox. length = 0;
Var c;
For (c = 0; c <arrFbox. length; c ++ ){
Var no = new Option ();
No. value = arrLookup [arrFbox [c];
No. text = arrFbox [c];
Fbox [c] = no;
}
For (c = 0; c <arrTbox. length; c ++ ){
Var no = new Option ();
No. value = arrLookup [arrTbox [c];
No. text = arrTbox [c];
Tbox [c] = no;
}
}
</Script>
</Body>