<Script language = "javascript1.2">
/*
This following code are designed and writen by windy_sk <windy_sk@126.com>
You can use it freely, but u must held all the copyright items!
*/
VaR mainsel = NULL;
VaR slavesel = NULL;
VaR item_org = new array ();
Function doadd (){
VaR this_sel = NULL;
For (VAR I = 0; I <mainsel. Options. length; I ++ ){
This_sel = mainsel. Options [I];
If (this_sel.selected ){
Slavesel. appendchild (this_sel );
I --;
}
}
Sort_main (slavesel );
}
Function dodel (){
VaR this_sel = NULL;
For (VAR I = 0; I <slavesel. Options. length; I ++ ){
This_sel = slavesel. Options [I];
If (this_sel.selected ){
Mainsel. appendchild (this_sel );
I --;
}
}
Sort_main (mainsel );
}
Function sort_main (the_sel ){
VaR this_sel = NULL;
For (VAR I = 0; I <item_org.length; I ++ ){
For (var j = 0; j <the_sel.options.length; j ++ ){
This_sel = the_sel.options [J];
If (this_sel.value = item_org [I] [0] & this_sel.text = item_org [I] [1]) {
The_sel.appendchild (this_sel );
}
}
}
}
Window. onload = function (){
Mainsel = select1;
Slavesel = select2;
Mainsel. ondblclick = doadd;
Slavesel. ondblclick = dodel;
VaR this_sel = NULL;
For (VAR I = 0; I <mainsel. Options. length; I ++ ){
This_sel = mainsel. Options [I];
Item_org.push (new array (this_sel.value, this_sel.text ));
}
}
</SCRIPT>
<Table width = "300" border = "0" cellspacing = "0" cellpdoadding = "0" align = "center">
<Tr>
& Lt; TD width = "45%" align = "center" & gt;
<Select id = "select1" size = "5" multiple style = "width: 100px">
<Option value = "111"> 111 </option>
<Option value = "222"> 222 </option>
<Option value = "333"> 333 </option>
<Option value = "444"> 444 </option>
<Option value = "555"> 555 </option>
<Option value = "666"> 666 </option>
<Option value = "777"> 777 </option>
<Option value = "888"> 888 </option>
<Option value = "999"> 999 </option>
</SELECT>
</TD>
& Lt; TD width = "10%" align = "center" & gt;
<Input name = "doadd" type = "button" value = ">" onclick = "doadd ()"> <br>
<Input name = "dodel" type = "button" value = "<" onclick = "dodel ()">
</TD>
& Lt; TD width = "45%" align = "center" & gt;
<Select id = "select2" size = "5" multiple style = "width: 100px">
</SELECT>
</TD>
</Tr>
</Table>