Copy codeThe Code is as follows:
<%
Dim
A = split (Request. Form ("sourceList "),",")
Response. write "Source:" & Request. form ("sourceList") & ubound (a) & "<br> Object:" & Request. form ("objectList") & "<br>"
%>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> Untitled Document </title>
<STYLE type = text/css>
. Bgsubleft {
BACKGROUND-POSITION: center bottom; BACKGROUND-IMAGE: url (images/bgleft.gif); BACKGROUND-REPEAT: repeat-x
}
. Bgsubleftn {
BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: url (images/bgleftn.gif); BACKGROUND-REPEAT: no-repeat
}
</STYLE>
<Script language = "JavaScript" type = "text/JavaScript">
Function addSelectedList ()
{
Var objSource = form1.sourceList;
Var objObject = form1.objectList;
Var sourcelen = objSource. length;
For (var I = 0; I <sourcelen; I ++ ){
If (objSource. options [I]. selected ){
If (! CheckExist (objObject, objSource. options [I]. value )){
Addtolist (objObject, objSource. options [I]. text, objSource. options [I]. value );
}
}
}
}
Function addAllList ()
{
Var objSource = form1.sourceList;
Var objObject = form1.objectList;
Var sourcelen = objSource. length;
For (var I = 0; I <sourcelen; I ++ ){
If (! CheckExist (objObject, objSource. options [I]. value )){
Addtolist (objObject, objSource. options [I]. text, objSource. options [I]. value );
}
}
}
Function removeSelectedList (noRemoveValue)
{
Var objObject = form1.objectList;
For (var I = 0; I <objObject. length; I ++ ){
If (objObject. options [I]. selected & objObject. options [I]. value! = NoRemoveValue)
{
ObjObject. options. remove (I );
RemoveList (noRemoveValue); break;
}
}
}
Function removeAllList (noRemoveValue)
{
Var objObject = form1.objectList;
Var objLen = objObject. length;
For (var I = 0; I <objLen; I ++ ){
If (objObject. options [I]. value! = NoRemoveValue ){
ObjObject. options. remove (I );
RemoveAllList (noRemoveValue); break;
}
}
}
Function selectedAll (obj)
{
For (var I = 0; I <obj. length; I ++ ){
Obj. options [I]. selected = true;
}
}
Function checkExist (obj, value)
{
Var isExist = false;
For (var I = 0; I <obj. length; I ++ ){
If (obj. options [I]. value = value ){
IsExist = true;
Break;
}
}
Return isExist;
}
Function addtolist (obj, value, label ){
Obj. add (new Option (value, label ));
}
</Script>
</Head>
<Body bgcolor = "# FFFFFF">
<Form name = "form1" action = "temp. asp" method = "post">
<Table width = "200" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td> <select name = "sourceList" size = "10" multiple id = "sourceList" style = "width: 150">
<Option value = "a"> 1 </option>
<Option value = "B"> 2 </option>
<Option value = "c"> 3 </option>
<%
For I = 6 to 20
Response. Write ("<option value =" "& I + 200 &" ">" & I + 200 & "</option>" & vbcrlf)
Next
%>
</Select> </td>
<Td> <input name = "add" type = "button" id = "add" value = "Add" onclick = "addSelectedList ()" style = "width: 100 "> <br>
<Input name = "add" type = "button" id = "add" value = "Add all" onclick = "addAllList ()" style = "width: 100 "> <br>
<Input name = "add" type = "button" id = "add" value = "Remove" onclick = "removeSelectedList ('A')" style = "width: 100 "> <br>
<Input name = "add" type = "button" id = "add" value = "Remove all" onclick = "removeAllList ('A')" style = "width: 100 ">
<Input name = "add" type = "button" id = "add" value = "Select all" onclick = "selectedAll (form1.objectList)" style = "width: 100 "> </td>
<Td> <select name = "objectList" size = "10" multiple id = "objectList" style = "width: 150">
<Option value = "a"> 1 </option>
<Option value = "d"> 4 </option>
<Option value = "e"> 5 </option>
<%
For I = 6 to 20
Response. Write ("<option value =" & I & ""> "& I &" </option> "& vbcrlf)
Next
%>
</Select> </td>
</Tr>
<Tr>
<Td> </td>
<Td> <input name = "subm" type = "submit" value = "Submit" style = "width: 100"> </td>
<Td> </td>
</Tr>
</Table>
</Form>
</Body>
</Html>