Subversion Repositories wimsdev

Rev

Rev 7479 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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