日期:2014-05-16 浏览次数:20485 次
<table border="1">
<tr>
<td>
<select id="select1" style="width:100px" size="10" multiple="multiple">
<option value="选项1">选项1</option>
<option value="选项2">选项2</option>
<option value="选项3">选项3</option>
<option value="选项4">选项4</option>
<option value="选项5">选项5</option>
<option value="选项6">选项6</option>
<option value="选项7">选项7</option>
<option value="选项8">选项8</option>
<option value="选项9">选项9</option>
</select>
</td>
<td align="center">
<input type="button" onclick="sel1AddTosel2()" value="-->"/><br/>
<input type="button" onclick="sel1AddAllTosel2('select1','select2')" value="==>"/><br/>
<input type="button" onclick="sel1AddTosel2('select2','select1')" value="<--"/><br/>
<input type="button" onclick="sel1AddAllTosel2('select2','select1')" value="<=="/>
</td>
<td>
<select id="select2" style="width:100px" size="10" multiple="multiple"></select>
</td>
</tr>
</table>
<script type="text/javascript">
function moveOption(l,i){
var s1=document.getElementById("select"+l);
var s2=document.getElementById("select"+(l==2?1:2));
for(var n = s1.options.length - 1; n >= 0; n--){
if((s1[n].selected == true&&1==i)
------解决方案--------------------
2==i){
var option=new Option(s1.options[n].innerHTML,s1.options[n].value);
s2.add(option);
s1.options.remove(n);
}
}
}
</script>