<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td>
<select id="dest" SIZE=10 multiple="multiple">
<option VALUE="1"> 001 </option>
<option VALUE="2"> 002 </option>
<option VALUE="3"> 003 </option>
</select>
</td>
<td>
<INPUT type=button id="copyA" value="<-copy" οnclick="copyToLeftA()" />
<br/>
<INPUT type=button id="copyB" value="copy->" οnclick="copyToLeftB()" />
</td>
<td>
<select id="srcv" SIZE=10 multiple>
<option VALUE="4"> 004 </option>
<option VALUE="5"> 005 </option>
<option VALUE="6"> 006 </option>
</select>
</td>
</tr>
</table>
</body>
<script language=JavaScript>
var srcv = document.getElementById("srcv");
var dest = document.getElementById("dest");
if(srcv.length<1){
document.getElementById("copyA").style.display = "none";
}
if(dest.length<1){
document.getElementById("copyB").style.display = "none";
}
function copyToLeftA(){
if(srcv.selectedIndex =='-1' ) {
alert("Please choose job !");
return false;
}
for(var i=0;i<srcv.length;i++){
if(srcv.options[i].selected){
var myOption=document.createElement("option");
myOption.setAttribute("value",srcv[i].value);
var optionText= document.createTextNode(srcv[i].text);
dest.add(myOption);
myOption.appendChild(optionText);
srcv.remove(i--);
}
}
if(srcv.length<1){
document.getElementById("copyA").style.display = "none";
}else{
document.getElementById("copyA").style.display = "";
}
if(dest.length<1){
document.getElementById("copyB").style.display = "none";
}else{
document.getElementById("copyB").style.display = "";
}
/*var dest = document.getElementById("dest");
var selectNumB=dest.selectedIndex;
if(selectNumA!='-1'){
var myOption=document.createElement("option");
myOption.setAttribute("value",srcv[selectNumA].value);
var optionText= document.createTextNode(srcv[selectNumA].text);
dest.add(myOption);
myOption.appendChild(optionText);
srcv.remove(selectNumA);
}
if(selectNumB!='-1'){
var myOption=document.createElement("option");
myOption.setAttribute("value",dest[selectNumB].value);
var optionText= document.createTextNode(dest[selectNumB].text);
srcv.add(myOption);
myOption.appendChild(optionText);
dest.remove(selectNumB);
}*/
}
function copyToLeftB(){
if(dest.selectedIndex =='-1' ) {
alert("Please choose job !");
return false;
}
for(var i=0;i<dest.length;i++){
if(dest.options[i].selected){
var myOption=document.createElement("option");
myOption.setAttribute("value",dest[i].value);
var optionText= document.createTextNode(dest[i].text);
srcv.add(myOption);
myOption.appendChild(optionText);
dest.remove(i--);
}
}
if(srcv.length<1){
document.getElementById("copyA").style.display = "none";
}else{
document.getElementById("copyA").style.display = "";
}
if(dest.length<1){
document.getElementById("copyB").style.display = "none";
}else{
document.getElementById("copyB").style.display = "";
}
/*var dest = document.getElementById("dest");
var selectNumB=dest.selectedIndex;
if(selectNumA!='-1'){
var myOption=document.createElement("option");
myOption.setAttribute("value",srcv[selectNumA].value);
var optionText= document.createTextNode(srcv[selectNumA].text);
dest.add(myOption);
myOption.appendChild(optionText);
srcv.remove(selectNumA);
}
if(selectNumB!='-1'){
var myOption=document.createElement("option");
myOption.setAttribute("value",dest[selectNumB].value);
var optionText= document.createTextNode(dest[selectNumB].text);
srcv.add(myOption);
myOption.appendChild(optionText);
dest.remove(selectNumB);
}*/
}
</script>
</html>