下拉列表的搬移

html<html<head lang="en"<meta charset="UTF-8"<titletitle</head<body<table<tr<td<select name="sel1" id="sel1" multiple style="width: 120px;" size="8"
<option</option<option</option<option</option<option</option<option</option<option</option<option</option
</select</td<td<input type="button" onclick="lefttoright()" style="width: 50px;" value=" >>> "<br<input type="button" onclick="singletoright()" style="width: 50px;" value=" >> "</td<td<select name="sel2" id="sel2" multiple style="width: 120px;" size="8"select</td</tr</table<scriptfunction singletoright(){
var sel1 = document.getElementById('sel1');
var sel2 = document.getElementById('sel2');
while(sel1.selectedIndex >= 0){
sel2.appendChild(sel1.options[sel1.selectedIndex]);
}
}
function lefttoright(){
var sel1 = document.getElementById('sel1');
var sel2 = document.getElementById('sel2');

for( ; sel1.options.length>0; ){
sel2.appendChild(sel1.options[0]);
}

}
script</body</html>
posted @ 2017-03-12 21:33  胡智杰  阅读(116)  评论(0编辑  收藏  举报