javascript|项目<script language="javascript">
function LeftToRight(Left,Right){ //左边加到右边
for(var i=Left.length-1;i>=0;i--){
if(Left.options[i].selected){
var j = Right.options.length - 1;
for (; j >= 0; j--) {
if (Left.options(i).value == Right.item(j).value) {
break;
}
}
if (j<0) {
var op = document.createElement("OPTION");
op.text=Left.options[i].text;
op.value=Left.options[i].value;
Right.add(op);
//Left.options[i] = null;
}
}
}
}
function RightToLeft(Right,Left){ //右边加到左边
for(var i=Right.length-1;i>=0;i--){
if(Right.options[i].selected){
var op = document.createElement("OPTION");
op.text=Right.options[i].text;
op.value=Right.options[i].value;
Left.add(op);
Right.options[i] = null;
}
}
}
function RightToRemove(Str){ //从右边移除
for(var i=Str.length-1;i>=0;i--){
if(Str.options[i].selected){
Str.options[i] = null;
}
}
}
</script>
<SELECT NAME="left" size="10" multiple="true">
<option value="1">AAA</option>
<option value="2">BBB</option>
<option value="3">CCC</option>
<option value="4">DDD</option>
<option value="5">EEE</option>
</SELECT>
<input type="button" value="--->" ><br/>
<br/>
<input type="button" value="<---" ><Br /><Br />
<input type="button" value="<-->" >
<SELECT NAME="right" size="10" multiple="true" ></SELECT>
在javascript中实现列表框项目转移
80酷酷网 80kuku.com