Rev 5796 | Rev 12784 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2788 | guerimand | 1 | <script type="text/javascript"> |
7479 | bpr | 2 | /*<![CDATA[*/ |
2788 | guerimand | 3 | function moveSelections(selectLeft, selectRight, selectHidden, action) { |
7479 | bpr | 4 | var menuFrom; var menuTo; var i ; |
2788 | guerimand | 5 | if (action == 'add') { |
6 | menuFrom = selectLeft; |
||
7 | menuTo = selectRight; |
||
8 | } |
||
9 | else { |
||
10 | menuFrom = selectRight; |
||
11 | menuTo = selectLeft; |
||
12 | } |
||
13 | // Don't do anything if nothing selected. Otherwise we throw javascript errors. |
||
14 | if (menuFrom.selectedIndex == -1) { |
||
15 | return; |
||
16 | } |
||
17 | |||
18 | // Add items to the 'TO' list. |
||
19 | for (i=0; i < menuFrom.length; i++) { |
||
20 | if (menuFrom.options[i].selected == true ) { |
||
21 | menuTo.options[menuTo.length]= new Option(menuFrom.options[i].text, menuFrom.options[i].value); |
||
22 | } |
||
23 | } |
||
24 | |||
25 | // Remove items from the 'FROM' list. |
||
26 | for (i=(menuFrom.length - 1); i>=0; i--){ |
||
27 | if (menuFrom.options[i].selected == true ) { |
||
28 | menuFrom.options[i] = null; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | // Set the appropriate items as 'selected in the hidden select. |
||
33 | // These are the values that will actually be posted with the form. |
||
34 | updateHidden(selectHidden, selectRight); |
||
35 | } |
||
36 | |||
37 | function updateHidden(h,r) { |
||
38 | for (var i=0; i < h.length; i++) { |
||
39 | h.options[i].selected = false; |
||
40 | } |
||
41 | |||
42 | for (i=0; i < r.length; i++) { |
||
43 | h.options[h.length] = new Option(r.options[i].text, r.options[i].value); |
||
44 | h.options[h.length-1].selected = true; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | function moveUp(l,h) { |
||
49 | var indice = l.selectedIndex; |
||
50 | if (indice < 0) { |
||
51 | return; |
||
52 | } |
||
53 | if (indice > 0) { |
||
54 | moveSwap(l, indice, indice-1); |
||
55 | updateHidden(h, l); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | function moveDown(l,h) { |
||
60 | var indice = l.selectedIndex; |
||
61 | if (indice < 0) { |
||
62 | return; |
||
63 | } |
||
64 | if (indice < l.options.length-1) { |
||
65 | moveSwap(l, indice, indice+1); |
||
66 | updateHidden(h, l); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | function moveSwap(l,i,j) { |
||
71 | var valeur = l.options[i].value; |
||
72 | var texte = l.options[i].text; |
||
73 | l.options[i].value = l.options[j].value; |
||
74 | l.options[i].text = l.options[j].text; |
||
75 | l.options[j].value = valeur; |
||
76 | l.options[j].text = texte; |
||
77 | l.selectedIndex = j |
||
78 | } |
||
79 | |||
80 | /* end javascript for HTML_QuickForm_advmultiselect */ |
||
7479 | bpr | 81 | /*]]>*/ |
2788 | guerimand | 82 | </script> |