//现在 只能 单个的移动 想要 按住ctrl能移动好几个 不知道 扎办了。
<!DCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; ">
<title>ListBoxTest </title>
<script type="text/javascript"> <!--
function moveList(from,to){
var fromList = document.myForm.elements[ListBox1];
var fromLen = fromList.options.length;
var toList = document.myForm.elements[ListBox2];
var toLen = toList.options.length;
var current= fromList.selectedIndex;
}window.onload = function() {
document.getElementById("btnMoveRight").onclick = moveItems;
document.getElementById("btnMoveLeft").onclick = moveItems;
document.getElementById("btnMoveRight2").onclick = moveItems1;
document.getElementById("btnMoveLeft2").onclick = moveItems1;
}
function moveItems1() {
var leftBox = document.getElementById("ListBox1");
var rightBox = document.getElementById("ListBox3");
var fromBox, toBox;
if (this.value == "-->") {
fromBox = leftBox; toBox = rightBox;
}
else if (this.value == " <--") {
fromBox = rightBox; toBox = leftBox;
fromBox.remove(fromBox.selectedIndex);
}
if ((fromBox != null) && (toBox != null)) {
if(fromBox.length < 1) {
return false;
}
while ( fromBox.selectedIndex >= 0 ) {
var newOption = new Option();
newOption.text = fromBox.options[fromBox.selectedIndex].text;
newOption.value = fromBox.options[fromBox.selectedIndex].value;
toBox.options[toBox.length] = newOption;
fromBox.copy(fromBox.selectedIndex);
}
}
return false;
}
function moveItems() {
var leftBox = document.getElementById("ListBox1");
var rightBox = document.getElementById("ListBox2");
var fromBox, toBox;
if (this.value == "-->") {
fromBox = leftBox; toBox = rightBox;
}
else if (this.value == " <--") {
fromBox = rightBox; toBox = leftBox;
fromBox.remove(fromBox.selectedIndex);
}
if ((fromBox != null) && (toBox != null)) {
if(fromBox.length < 1) {
return false;
}
while ( fromBox.selectedIndex >= 0 ) {
var newOption = new Option();
newOption.text = fromBox.options[fromBox.selectedIndex].text;
newOption.value = fromBox.options[fromBox.selectedIndex].value;
toBox.options[toBox.length] = newOption;
fromBox.copy(fromBox.selectedIndex);
}
}
return false;
} //-->
</script>
</head>
<body>
<table>
<tr>
<td>
<select id="ListBox1" size="5" multiple="multiple">
<option value="1">Item1 </option>
<option value="2">Item2 </option>
<option value="3">Item3 </option>
<option value="4">Item4 </option>
<option value="5">Item5 </option>
</select>
</td>
<td>
<input id="btnMoveRight" type="button" value="-->" />
<br />
<input id="btnMoveLeft" type="button" value=" <--" />
</td>
<td>
<select id="ListBox2" size="5" multiple="multiple">
</select>
</td>
</tr> <tr>
<td>
</td>
<td>
<input id="btnMoveRight2" type="button" value="-->" />
<br />
<input id="btnMoveLeft2" type="button" value=" <--" />
</td>
<td>
<select id="ListBox3" size="5" multiple="multiple">
</select>
</td>
</tr>
</table>
</body>
</html>
<!DCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; ">
<title>ListBoxTest </title>
<script type="text/javascript"> <!--
function moveList(from,to){
var fromList = document.myForm.elements[ListBox1];
var fromLen = fromList.options.length;
var toList = document.myForm.elements[ListBox2];
var toLen = toList.options.length;
var current= fromList.selectedIndex;
}window.onload = function() {
document.getElementById("btnMoveRight").onclick = moveItems;
document.getElementById("btnMoveLeft").onclick = moveItems;
document.getElementById("btnMoveRight2").onclick = moveItems1;
document.getElementById("btnMoveLeft2").onclick = moveItems1;
}
function moveItems1() {
var leftBox = document.getElementById("ListBox1");
var rightBox = document.getElementById("ListBox3");
var fromBox, toBox;
if (this.value == "-->") {
fromBox = leftBox; toBox = rightBox;
}
else if (this.value == " <--") {
fromBox = rightBox; toBox = leftBox;
fromBox.remove(fromBox.selectedIndex);
}
if ((fromBox != null) && (toBox != null)) {
if(fromBox.length < 1) {
return false;
}
while ( fromBox.selectedIndex >= 0 ) {
var newOption = new Option();
newOption.text = fromBox.options[fromBox.selectedIndex].text;
newOption.value = fromBox.options[fromBox.selectedIndex].value;
toBox.options[toBox.length] = newOption;
fromBox.copy(fromBox.selectedIndex);
}
}
return false;
}
function moveItems() {
var leftBox = document.getElementById("ListBox1");
var rightBox = document.getElementById("ListBox2");
var fromBox, toBox;
if (this.value == "-->") {
fromBox = leftBox; toBox = rightBox;
}
else if (this.value == " <--") {
fromBox = rightBox; toBox = leftBox;
fromBox.remove(fromBox.selectedIndex);
}
if ((fromBox != null) && (toBox != null)) {
if(fromBox.length < 1) {
return false;
}
while ( fromBox.selectedIndex >= 0 ) {
var newOption = new Option();
newOption.text = fromBox.options[fromBox.selectedIndex].text;
newOption.value = fromBox.options[fromBox.selectedIndex].value;
toBox.options[toBox.length] = newOption;
fromBox.copy(fromBox.selectedIndex);
}
}
return false;
} //-->
</script>
</head>
<body>
<table>
<tr>
<td>
<select id="ListBox1" size="5" multiple="multiple">
<option value="1">Item1 </option>
<option value="2">Item2 </option>
<option value="3">Item3 </option>
<option value="4">Item4 </option>
<option value="5">Item5 </option>
</select>
</td>
<td>
<input id="btnMoveRight" type="button" value="-->" />
<br />
<input id="btnMoveLeft" type="button" value=" <--" />
</td>
<td>
<select id="ListBox2" size="5" multiple="multiple">
</select>
</td>
</tr> <tr>
<td>
</td>
<td>
<input id="btnMoveRight2" type="button" value="-->" />
<br />
<input id="btnMoveLeft2" type="button" value=" <--" />
</td>
<td>
<select id="ListBox3" size="5" multiple="multiple">
</select>
</td>
</tr>
</table>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货