@@ -7,13 +7,16 function addOption(theSel, theText, theValue) { | |||||
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | function swapOptions(theSel, index1, index2) { |
|
9 | function swapOptions(theSel, index1, index2) { | |
10 | var text, value; |
|
10 | var text, value, selected; | |
11 | text = theSel.options[index1].text; |
|
11 | text = theSel.options[index1].text; | |
12 | value = theSel.options[index1].value; |
|
12 | value = theSel.options[index1].value; | |
|
13 | selected = theSel.options[index1].selected; | |||
13 | theSel.options[index1].text = theSel.options[index2].text; |
|
14 | theSel.options[index1].text = theSel.options[index2].text; | |
14 | theSel.options[index1].value = theSel.options[index2].value; |
|
15 | theSel.options[index1].value = theSel.options[index2].value; | |
|
16 | theSel.options[index1].selected = theSel.options[index2].selected; | |||
15 | theSel.options[index2].text = text; |
|
17 | theSel.options[index2].text = text; | |
16 | theSel.options[index2].value = value; |
|
18 | theSel.options[index2].value = value; | |
|
19 | theSel.options[index2].selected = selected; | |||
17 | } |
|
20 | } | |
18 |
|
21 | |||
19 | function deleteOption(theSel, theIndex) { |
|
22 | function deleteOption(theSel, theIndex) { | |
@@ -44,40 +47,54 function moveOptions(theSelFrom, theSelTo) { | |||||
44 | } |
|
47 | } | |
45 |
|
48 | |||
46 | function moveOptionUp(theSel) { |
|
49 | function moveOptionUp(theSel) { | |
47 | var index = theSel.selectedIndex; |
|
50 | var indexTop = 0; | |
48 | if (index > 0) { |
|
51 | for(var s=0; s<theSel.length; s++) { | |
49 | swapOptions(theSel, index-1, index); |
|
52 | if (theSel.options[s].selected) { | |
50 | theSel.selectedIndex = index-1; |
|
53 | if (s > indexTop) { | |
|
54 | swapOptions(theSel, s-1, s); | |||
|
55 | } | |||
|
56 | indexTop++; | |||
|
57 | } | |||
51 | } |
|
58 | } | |
52 | } |
|
59 | } | |
53 |
|
60 | |||
54 | function moveOptionTop(theSel) { |
|
61 | function moveOptionTop(theSel) { | |
55 | var index = theSel.selectedIndex; |
|
62 | var indexTop = 0; | |
56 |
|
63 | for(var s=0; s<theSel.length; s++) { | ||
57 | if (index > 0) { |
|
64 | if (theSel.options[s].selected) { | |
58 | for (i=index; i>0; i--) { |
|
65 | if (s > indexTop) { | |
59 | swapOptions(theSel, i-1, i); |
|
66 | for (var i=s; i>indexTop; i--) { | |
|
67 | swapOptions(theSel, i-1, i); | |||
|
68 | } | |||
|
69 | } | |||
|
70 | indexTop++; | |||
60 | } |
|
71 | } | |
61 | theSel.selectedIndex = 0; |
|
|||
62 | } |
|
72 | } | |
63 | } |
|
73 | } | |
64 |
|
74 | |||
65 | function moveOptionDown(theSel) { |
|
75 | function moveOptionDown(theSel) { | |
66 |
var index = theSel. |
|
76 | var indexBottom = theSel.length - 1; | |
67 | if (index < theSel.length - 1) { |
|
77 | for(var s=indexBottom; s>=0; s--) { | |
68 | swapOptions(theSel, index, index+1); |
|
78 | if (theSel.options[s].selected) { | |
69 | theSel.selectedIndex = index+1; |
|
79 | if (s < indexBottom) { | |
|
80 | swapOptions(theSel, s+1, s); | |||
|
81 | } | |||
|
82 | indexBottom--; | |||
|
83 | } | |||
70 | } |
|
84 | } | |
71 | } |
|
85 | } | |
72 |
|
86 | |||
73 | function moveOptionBottom(theSel) { |
|
87 | function moveOptionBottom(theSel) { | |
74 |
var index = theSel. |
|
88 | var indexBottom = theSel.length - 1; | |
75 | var indexTop = theSel.length - 1; |
|
89 | for(var s=indexBottom; s>=0; s--) { | |
76 | if (index < theSel.length - 1) { |
|
90 | if (theSel.options[s].selected) { | |
77 | for (i=index; i<indexTop; i++) { |
|
91 | if (s < indexBottom) { | |
78 | swapOptions(theSel, i+1, i); |
|
92 | for (i=s; i<indexBottom; i++) { | |
|
93 | swapOptions(theSel, i+1, i); | |||
|
94 | } | |||
|
95 | } | |||
|
96 | indexBottom--; | |||
79 | } |
|
97 | } | |
80 | theSel.selectedIndex = indexTop; |
|
|||
81 | } |
|
98 | } | |
82 | } |
|
99 | } | |
83 |
|
100 |
General Comments 0
You need to be logged in to leave comments.
Login now