说明: 是 上 一 回 程 式 的 改 进 版!
本程式支持排序,Shift和Ctrl功能!(即:连选和跳选多项Option)
可以任意的相互操作(下拉列表框1<=>下拉列表框2)!
如果多维数组复杂,可以自己写一个排序函数!
JavaScript中Sort()所传的参数为数组的俩个RECORD(我的定义),默认按
字符排序。
排序所传的参数也为一个数组,例数组A 为下所示:
a[0][0]=1;
a[0][1]=2;
a[0][2]=3;
a[0][3]=4;
a[1][0]=1;
a[1][1]=2;
a[1][2]=3;
a[1][3]=4;
a[2][0]=1;
a[2][1]=2;
a[2][2]=3;
a[2][3]=4;
每次所传的参数为下:
a[0]={1,2,3,4}
a[1]={1,2,3,4}
。。。。。。。
那么自己根据要求就可以对传来的参数数组(实际为数组中的RECORD)
中的某一个FIELD进行排序!
select.htm
function fun_select_addany(theform){
var i;
for (i=0;i if (theform.left_select.options[i].selected == true){ theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text); theform.left_select.options.remove(i); i--; } } sort_select(document.myform); } function fun_select_addall(theform){ var i; for (i=0;i theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text); } theform.left_select.length=0; sort_select(document.myform); } function fun_select_dltany(theform){ var i; for (i=0;i if (theform.right_select.options[i].selected == true){ theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text); theform.right_select.options[i] =new Option(""); theform.right_select.options.remove(i); i--; } } sort_select(document.myform); } function fun_select_dltall(theform){ var i; for (i=0;i theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text); } theform.right_select.length=0; sort_select(document.myform); } function sort_select(theform){ var i; var left_array= new Array(); var right_array = new Array(); for (i=0;i left_array[i] = new Array(theform.left_select.options[i].text); } for (i=0;i right_array[i] = new Array(theform.right_select.options[i].text); } left_array.sort(); right_array.sort(); theform.left_select.length=0; theform.right_select.length=0; for (i=0;i theform.left_select.options[theform.left_select.length]=new Option(left_array[i]); } for (i=0;i theform.right_select.options[theform.right_select.length]=new Option(right_array[i]); } left_array= new Array(); right_array = new Array(); }

