87,990
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
//移动选中项
function moveSelectedItem(selectSource,selectTarget) {
for (var i = 0; i < selectSource.options.length; i++) {
if (selectSource.options[i].selected)
{
selectTarget.appendChild(selectSource.options[i]);
}
}
selectSource.selectedIndex = -1;
selectTarget.selectedIndex = -1;
}
//左移动到右
function moveToRight() {
var selectLeftObj = document.getElementById("selectLeft");
var selectRightObj = document.getElementById("selectRight");
moveSelectedItem(selectLeftObj, selectRightObj);
}
</script>
</head>
<body>
<table id="tableContent" border="1" style="background-color:Fuchsia">
<tr>
<td>
<select id="selectLeft" multiple="multiple" style="height:120px; width:100px">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="F">F</option>
</select>
</td>
<td>
<input type="button" value=">" style="width:50px; height:20px" onclick="moveToRight();" /><br />
</td>
<td>
<select id="selectRight" multiple="multiple" style="height:120px;width:100px"></select>
</td>
</tr>
</table>
</body>
</html>
//复制选中项
function copeSelectedItem(selectSource,selectTarget) {
for (var i = 0; i < selectSource.options.length; i++) {
if (selectSource.options[i].selected)
{
selectTarget.add(new Option(selectSource.options[i].value,selectSource.options[i].text));
}
}
selectSource.selectedIndex = -1;
selectTarget.selectedIndex = -1;
}