让Select列表各项上移和下移的Js代码
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
select列表各项上移和下移的js代码,可以手功排序,以前我们都见到过的,从事web编程的朋友经常会用得到。 [br][code]
<script> function move(index,to) { var list = document.form.list; var total = list.options.length-1; if (index == -1) return false; if (to == +1 && index == total) return false; if (to == -1 && index == 0) return false; var items = new Array; var values = new Array; for (i = total; i >= 0; i--) { items[i] = list.options[i].text; values[i] = list.options[i].value; } for (i = total; i >= 0; i--) { if (index == i) { list.options[i + to] = new Option(items[i],values[i + to], 0, 1); list.options[i] = new Option(items[i + to], values[i]); i--; } else { list.options[i] = new Option(items[i], values[i]); } } list.focus(); } function submitForm() { var list = document.form.list; var theList = "?"; for (i = 0; i <= list.options.length-1; i++) { theList += "list" + list.options[i].value + "=" + list.options[i].text; if (i != list.options.length-1) theList += "&"; } location.href = document.form.action + theList; } </script> [/code] 该文章在 2010/3/8 0:27:02 编辑过 |
关键字查询
相关文章
正在查询... |