<html>
<head>
<title>Multi</title>
<script language="javascript">
function moveToList2(e){
if(e.selectedIndex!=-1){//判断是否有选择
for(var i=0;i<e.length;i++){
if(e.options[i].selected==true){
var len2=document.form1.list2.length-1;
var txt=e.options[i].text;
var value=e.options[i].value;
document.form1.list2.options[len2+1]=new Option(txt,value);
e.options[i]=null;
}
}
e.selectedIndex=-1;
}
}
function moveToList1(e){
if(e.selectedIndex!=-1){//判断是否有选择
for(var i=0;i<e.length;i++){
if(e.options[i].selected==true){
var len1=document.form1.list1.length-1;
var txt=e.options[i].text;
var value=e.options[i].value;
document.form1.list1.options[len1+1]=new Option(txt,value);
e.options[i]=null;
}
}
e.selectedIndex=-1;
}
}
</script>
</head>
<body>
<form action="" method="post" name="form1">
<table width="200" border="0" align="center">
<tr>
<td rowspan="5">
<select size="10" name="list1" multiple="multiple">
<option value="java">java</option>
<option value="jsp">jsp</option>
<option value="vb">vb</option>
<option value="delphi">delphi</option>
</select>
</td>
<td> </td>
<td rowspan="5">
<select size="10" name="list2" multiple="multiple">
<option value="asp">asp</option>
<option value="asp.net">asp.net</option>
<option value="php">php</option>
<option value="c++">c++</option>
</select>
</td>
</tr>
<tr>
<td align="center"><input type="button" value=" >> " onclick="moveToList2(document.form1.list1)"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center"><input type="button" value=" << " onclick="moveToList1(document.form1.list2)"></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
上面是我写的代码,在选择多个的情况下会出错误,1下午都没有解决好