下拉框的数据来回交换功能很实用,需要的朋友可以参考一下,希望对你有帮助
<html> <head> <title>列表数据交换</title> <script language="JavaScript"> function copyToList(from,to) { fromList = eval('document.forms[0].' + from); toList = eval('document.forms[0].' + to); if (toList.options.length > 0 && toList.options[0].value == 'temp') { toList.options.length = 0; } var sel = false; for (i=0;i<fromList.options.length;i++) { var current = fromList.options[i]; if (current.selected) { sel = true; if (current.value == 'temp') { alert ('你不能选择这个项目!'); return; } txt = current.text; val = current.value; toList.options[toList.length] = new Option(txt,val); fromList.options[i] = null; i--; } } if (!sel) alert ('你还没有选择任何项目'); } function allSelect() { List = document.forms[0].chosen; if (List.length && List.options[0].value == 'temp') return; for (i=0;i<List.length;i++) { List.options[i].selected = true; } } </script> </head> <body> <table border="0"> <form onSubmit="allSelect()"> <tr> <td> <select name="possible" size="4" MULTIPLE width=200 style="width: 200px"> <option value="1">长沙 <option value="2">天津 <option value="3">南京 <option value="4">武汉 <option value="5">郑州 </select> </td> <td><a href="javascript:copyToList('possible','chosen')">--><br> <br> </a><a href="javascript:copyToList('chosen','possible')"><--</a></td> <td> <select name="chosen" size="4" MULTIPLE width=200 style="width: 200px;"> <option value="temp">选择地区 </select> </td> </tr></form> </table> </body> </html>
[ 提示:你可先修改部分代码,再按Ctrl+A 全部选择 ]
很不错的一款日期输入控件特效...