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