Paste2 Logo
  1.        var leftlist ;
  2.         var rightlist ;
  3.         var varleftButton ;
  4.         var varrightButton;
  5. function init()
  6. {
  7. if(document.getElementById('leftButton')){
  8.          leftlist = document.getElementById('left');
  9.          rightlist = document.getElementById('right');
  10.          varleftButton = document.getElementById('leftButton');
  11.          varrightButton = document.getElementById('rightButton');
  12. }
  13.  
  14. }
  15. function toLeft()
  16. {
  17.  init();
  18. var newOption = document.createElement('option');
  19. newOption.setAttribute('value', rightlist.item(rightlist.selectedIndex).getAttribute("value"));
  20. newOption.text=rightlist.item(rightlist.selectedIndex).text;
  21.         leftlist.appendChild(newOption);
  22.         rightlist.remove(rightlist.selectedIndex);
  23.        
  24. }
  25. function toRight()
  26. {
  27.      init();
  28. var newOption = document.createElement('option');
  29. newOption.setAttribute('value', leftlist.item(leftlist.selectedIndex).getAttribute("value"));
  30. newOption.text=leftlist.item(leftlist.selectedIndex).text;
  31.         rightlist.appendChild(newOption);
  32.         leftlist.remove(leftlist.selectedIndex);
  33.        
  34. }
  35. function switchbutton()
  36. {
  37.         if(leftlist.length==0)
  38.         {
  39.                 varrightButton.disabled=true;
  40.                 varleftButton.disabled=false;
  41.         }
  42.         if(leftlist.length>0)
  43.         {
  44.                 varrightButton.disabled=false;
  45.  
  46.         }
  47.         if(rightlist.length==0)
  48.         {
  49.                 varleftButton.disabled=true;
  50.                 varrightButton.disabled=false;
  51.         }
  52. if(rightlist.length>0)
  53.         {
  54. varleftButton.disabled=false;
  55. }
  56.  
  57. }