下拉列表框,如何实现把一个列表框中的选项倒到另外一个列表框中?

如何实现把一个列表框中的选项倒到另外一个列表框中? - 故障解答 - 电脑教程网

如何实现把一个列表框中的选项倒到另外一个列表框中?

日期:2006-08-06   荐:
如何实现把一个列表框中的选项倒到另外一个列表框中?JavaScript 实现如题!<HTML><HEAD><TITLE>aaaaa</TITLE><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><META NAME="Description" CONTENT=""></HEAD><BODY><!-- meizz --><table border=0 cellpadding=0 cellspacing=0><form name=meizz> <tr><td> <select id=list1 size=8 ondblclick="moveOption(this, this.form.list2)"> <option value=A>aaaaaaaaaa <option value=B>bbbbbbbbbb <option value=C>cccccccccc <option value=D>dddddddddd <option value=E>eeeeeeeeee <option value=F>ffffffffff <option value=G>gggggggggg <option value=H>hhhhhhhhhh </select></td> <td width=40 align=center> <input name=add type=button value=">>>" onclick="moveOption(this.form.list1, this.form.list2)"><br><br> <input name=sub type=button value="<<<" onclick="moveOption(this.form.list2, this.form.list1)"> </td><td> <select id=list2 size=8 ondblclick="moveOption(this, this.form.list1)"> </select> </td></tr></form></table><script language="JavaScript"><!--function moveOption(e1, e2){ try{ var e = e1.options[e1.selectedIndex]; e2.options.add(new Option(e.text, e.value)); e1.options.remove(e1.selectedIndex); } catch(e){}}//--></script></BODY></HTML> <div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand"><input type="button" name="Button" value="" onClick= 'window.location = "view-source:" window.location.href'></div><script>function addoption(){var b=document.all.b;var a=document.all.a;for(i=0;i<a.length;i ){b.options[b.length ]=new Option(a.options[i].innerText,a.options[i].value);}}</script><select name="a"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option></select><select name="b"><option value="a">a</option><option value="b">b</option></select><input type="button" value="导入a->b" onclick="addoption()">
标签: