@@ -1,82 +1,82 | |||
|
1 | 1 | var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5); |
|
2 | 2 | |
|
3 | 3 | function addOption(theSel, theText, theValue) |
|
4 | 4 | { |
|
5 | 5 | var newOpt = new Option(theText, theValue); |
|
6 | 6 | var selLength = theSel.length; |
|
7 | 7 | theSel.options[selLength] = newOpt; |
|
8 | 8 | } |
|
9 | 9 | |
|
10 | 10 | function swapOptions(theSel, index1, index2) |
|
11 | 11 | { |
|
12 | 12 | var text, value; |
|
13 | 13 | text = theSel.options[index1].text; |
|
14 | 14 | value = theSel.options[index1].value; |
|
15 | 15 | theSel.options[index1].text = theSel.options[index2].text; |
|
16 | 16 | theSel.options[index1].value = theSel.options[index2].value; |
|
17 | 17 | theSel.options[index2].text = text; |
|
18 | 18 | theSel.options[index2].value = value; |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | function deleteOption(theSel, theIndex) |
|
22 |
{ |
|
|
22 | { | |
|
23 | 23 | var selLength = theSel.length; |
|
24 | 24 | if(selLength>0) |
|
25 | 25 | { |
|
26 | 26 | theSel.options[theIndex] = null; |
|
27 | 27 | } |
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | function moveOptions(theSelFrom, theSelTo) |
|
31 | 31 | { |
|
32 | ||
|
32 | ||
|
33 | 33 | var selLength = theSelFrom.length; |
|
34 | 34 | var selectedText = new Array(); |
|
35 | 35 | var selectedValues = new Array(); |
|
36 | 36 | var selectedCount = 0; |
|
37 | ||
|
37 | ||
|
38 | 38 | var i; |
|
39 | ||
|
39 | ||
|
40 | 40 | for(i=selLength-1; i>=0; i--) |
|
41 | 41 | { |
|
42 | 42 | if(theSelFrom.options[i].selected) |
|
43 | 43 | { |
|
44 | 44 | selectedText[selectedCount] = theSelFrom.options[i].text; |
|
45 | 45 | selectedValues[selectedCount] = theSelFrom.options[i].value; |
|
46 | 46 | deleteOption(theSelFrom, i); |
|
47 | 47 | selectedCount++; |
|
48 | 48 | } |
|
49 | 49 | } |
|
50 | ||
|
50 | ||
|
51 | 51 | for(i=selectedCount-1; i>=0; i--) |
|
52 | 52 | { |
|
53 | 53 | addOption(theSelTo, selectedText[i], selectedValues[i]); |
|
54 | 54 | } |
|
55 | ||
|
55 | ||
|
56 | 56 | if(NS4) history.go(0); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | function moveOptionUp(theSel) { |
|
60 | 60 | var index = theSel.selectedIndex; |
|
61 | 61 | if (index > 0) { |
|
62 | 62 | swapOptions(theSel, index-1, index); |
|
63 | 63 | theSel.selectedIndex = index-1; |
|
64 | 64 | } |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | function moveOptionDown(theSel) { |
|
68 | 68 | var index = theSel.selectedIndex; |
|
69 | 69 | if (index < theSel.length - 1) { |
|
70 | 70 | swapOptions(theSel, index, index+1); |
|
71 | 71 | theSel.selectedIndex = index+1; |
|
72 | 72 | } |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | function selectAllOptions(id) |
|
76 | 76 | { |
|
77 | 77 | var select = $(id); |
|
78 | 78 | for (var i=0; i<select.options.length; i++) { |
|
79 | 79 | select.options[i].selected = true; |
|
80 | 80 | } |
|
81 | 81 | } |
|
82 | 82 |
General Comments 0
You need to be logged in to leave comments.
Login now