<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>list Test </title>
<body>
<div style= "FONT-SIZE:10PT;" >
Note 1: Move left and right to select
<br/>
<br/>
Note: This page is only tested under ie6/firefox1.5. Other browsers or other versions have not been tested.
<br/>
</div>
<form name= "frm" >
<table>
<tr>
<td>
<select name= "Srcselect" size= "6" style= "FONT-SIZE:11PT; width:160px; height:160px "
Multiple= "multiple" ondblclick= "Moveleftorright (document.frm.srcselect,document.frm.objselect)" >
<option value= "1" > Lecturer </option>
</select>
</td>
<TD width= "30px" >
<input align= "left" type= "button" value= ">" onclick= "Moveleftorright (Document.frm.SrcSelect, Document.frm.ObjSelect) ">
<br>
<br>
<input align= "left" type= "button" value= "<" onclick= "Moveleftorright (Document.frm.ObjSelect, Document.frm.SrcSelect) ">
</td>
<td>
<select name= "Objselect" size= "6" style= "FONT-SIZE:11PT; width:160px; height:160px "
Multiple= "multiple" ondblclick= "Moveleftorright (document.frm.objselect,document.frm.srcselect)" >
<option value= "2" > Teaching Administrator </option>
<option value= "3" > Super admin </option>
</select>
</td>
</tr>
</table>
</form>
</body>
<script type= "Text/javascript" language= "JavaScript" >
Move Up
function MoveUp () {
var theobjoptions = document.frm.ObjSelect.options;
for (var i = 1; i < theobjoptions.length; i++) {
if (theobjoptions[i].selected &&!theobjoptions[i-1].selected) {
Swapoptionproperties (Theobjoptions[i], theobjoptions[i-1]);
}
}
}
Move Down
function MoveDown () {
var theobjoptions = document.frm.ObjSelect.options;
for (var i = theobjoptions.length-2 i > 1; i--) {
if (theobjoptions[i].selected &&!theobjoptions[i + 1].selected) {
Swapoptionproperties (Theobjoptions[i], theobjoptions[i + 1]);
}
}
}
function swapoptionproperties (option1, option2) {
var tempstr = Option1.value;
option1.value = option2.value;
option1.value = tempstr;
tempstr = Option1.text;
option1.text = Option2.text;
option2.text = tempstr;
tempstr = option1.selected;
option1.selected = option2.selected;
option2.selected = tempstr;
}
The position of the list box moves
function Moveleftorright (fromobj, toobj) {
for (var i = 0; i < fromobj.length; i++) {
var srcoption = fromobj.options[i];
if (srcoption.selected) {
Toobj.appendchild (srcoption);
i--;
}
}
}
</script>