列表框操作函数集合
1
/* 列表框互相操作函数集 */
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
//描述: 添加不重复列表框元素
4
function selAdd( srcList, dstList )
5
{
6
var selectedIndex = new Array();
7
var count = 0;
8![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
for ( i=0; i<srcList.options.length; i++ ){
10![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
if ( srcList.options[i].selected ){
12
13
selectedIndex[count] = i;
14
count ++;
15![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
}
17
}
18![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
for ( j=0; j<selectedIndex.length; j++ ){
20
21
k = selectedIndex[j];
22![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
if ( chkDup( srcList.options[k].value, dstList )==false ){
24
&, nbsp; dstList.options.length++;
25
var len = dstList.options.length-1;
26
dstList.options[len].value = srcList.options[k].value;
27
dstList.options[len].text = srcList.options[k].text;
28
}
29![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
}
31![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
}
33![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
//描述: 删除列表框元素
35
function selDel( list )
36
{
37
var len = list.options.length;
38
var idx = 0;
39![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
while ( idx< len ){
41![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
if ( list.options[idx].selected ){
43
list.options.remove(idx);
44
len = list.options.length;
45
}
46
else{
47
idx ++;
48
}
49
}
50
}
51![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
52
//描述: 检测列表框元素重复
53
function chkDup( item, list )
54
{
55
for ( i=0; i<list.options.length; i++ ){
56
//alert( item + " - " + list.options[i].value );
57
if ( item == list.options[i].value ){
58
return true;
59
}
60
}
61
return false;
62
}
63![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
64
//描述: 选择列表框的全部成员
65
function selSel( list, item )
66
{
67
item.value = " ";
68
for ( i=0; i<list.options.length; i++ ){
69
list.options[i].selected=true;
70
item.value += list.options[i].value + " ";
71
}
72![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
73
}
74![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
75
function selSelSingle( list, value )
76
{
77
for ( i=0; i<list.options.length; i++ ){
78
if ( list.options[i].value == value ){
79
list.options[i].selected=true;
80
break;
81
}
82
}
83![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
84
}
85
//描述: 根据数组初始化列表框
86
function selList( item, arr )
87
{
88![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
89
var curIndex, insIndex, val, text;
90
var arrItem = new Array();
91![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
92
if ( item ){
93![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
94
item.length = 0;
95
curIndex = 0;
96![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
97
for ( i=0; i<arr.length; i++ ){
98![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
99
item.length ++;
100
insIndex = item.length - 1;
101
102
if ( arr[i] ){
103
arrItem = arr[i].split( ", " );
104
text = arrItem[1];
105
val = arrItem[0];
106
item.options[ insIndex ].text = text;
107
item.options[ insIndex ].value= val;
108
}
109
}
110![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
111
}
112
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
44
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
46
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
48
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
49
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
50
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
51
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
52
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
53
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
54
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
55
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
56
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
57
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
58
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
59
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
60
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
61
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
62
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
63
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
64
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
65
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
66
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
67
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
68
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
69
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
70
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
71
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
72
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
73
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
74
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
75
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
76
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
77
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
78
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
79
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
80
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
81
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
82
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
83
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
84
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
85
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
86
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
87
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
88
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
89
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
90
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
91
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
92
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
93
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
94
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
95
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
96
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
97
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
98
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
99
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
100
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
101
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
102
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
103
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
104
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
105
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
106
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
107
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
108
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
109
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
110
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
111
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
112
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)