- var leftlist ;
- var rightlist ;
- var varleftButton ;
- var varrightButton;
- function init()
- {
- if(document.getElementById('leftButton')){
- leftlist = document.getElementById('left');
- rightlist = document.getElementById('right');
- varleftButton = document.getElementById('leftButton');
- varrightButton = document.getElementById('rightButton');
- }
- }
- function toLeft()
- {
- init();
- var newOption = document.createElement('option');
- newOption.setAttribute('value', rightlist.item(rightlist.selectedIndex).getAttribute("value"));
- newOption.text=rightlist.item(rightlist.selectedIndex).text;
- leftlist.appendChild(newOption);
- rightlist.remove(rightlist.selectedIndex);
- }
- function toRight()
- {
- init();
- var newOption = document.createElement('option');
- newOption.setAttribute('value', leftlist.item(leftlist.selectedIndex).getAttribute("value"));
- newOption.text=leftlist.item(leftlist.selectedIndex).text;
- rightlist.appendChild(newOption);
- leftlist.remove(leftlist.selectedIndex);
- }
- function switchbutton()
- {
- if(leftlist.length==0)
- {
- varrightButton.disabled=true;
- varleftButton.disabled=false;
- }
- if(leftlist.length>0)
- {
- varrightButton.disabled=false;
- }
- if(rightlist.length==0)
- {
- varleftButton.disabled=true;
- varrightButton.disabled=false;
- }
- if(rightlist.length>0)
- {
- varleftButton.disabled=false;
- }
- }
