1
/*列表框互相操作函数集*/
2
3
//描述:添加不重复列表框元素
4
functionselAdd(srcList,dstList)
5
{
6
varselectedIndex=newArray();
7
varcount=0;
8
9
for(i=0;i<srcList.options.length;i++){
10
11
if(srcList.options[i].selected){
12
13
selectedIndex[count]=i;
14
count++;
15
16
}
17
}
18
19
for(j=0;j<selectedIndex.length;j++){
20
21
k=selectedIndex[j];
22
23
if(chkDup(srcList.options[k].value,dstList)==false){
24
&,nbsp;dstList.options.length++;
25
varlen=dstList.options.length-1;
26
dstList.options[len].value=srcList.options[k].value;
27
dstList.options[len].text=srcList.options[k].text;
28
}
29
30
}
31
32
}
33
34
//描述:删除列表框元素
35
functionselDel(list)
36
{
37
varlen=list.options.length;
38
varidx=0;
39
40
while(idx<len){
41
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
52
//描述:检测列表框元素重复
53
functionchkDup(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
returntrue;
59
}
60
}
61
returnfalse;
62
}
63
64
//描述:选择列表框的全部成员
65
functionselSel(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
73
}
74
75
functionselSelSingle(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
84
}
85
//描述:根据数组初始化列表框
86
functionselList(item,arr)
87
{
88
89
varcurIndex,insIndex,val,text;
90
vararrItem=newArray();
91
92
if(item){
93
94
item.length=0;
95
curIndex=0;
96
97
for(i=0;i<arr.length;i++){
98
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
111
}
112
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112
