var NbSource; var NbCible ; var nbAjout=0; var colors = ['#f4f6e3','#75c1d1','#89d8b5','#33869c']; // Initialize NbSource & NbCible function initVars(agencesKO,agencesOK) { NbSource = agencesKO; NbCible = agencesOK; } // ADD function Ajouter(){ var NbEle = -1; var moved = 0; var TxtEle = ''; var valueEle=''; var lstSourceElmt = document.myForm.lstSource; var lstCibleElmt = document.myForm.lstCible; var userTypeElmt = document.myForm.userType; var longu = lstSourceElmt.length; for(i = 0; i < longu; i++){ if (lstSourceElmt.options[(i-moved)].selected) { NbEle = (i - moved); TxtEle = lstSourceElmt.options[(i - moved)].text; valueEle = lstSourceElmt.options[(i - moved)].value; if (NbSource != 0 && NbEle != -1){ addOption(lstSourceElmt.options[NbEle].value); addZones(lstSourceElmt.options[NbEle].value); // lstSourceElmt.options[NbEle] = null; // lstCibleElmt.options[NbCible] = new Option(TxtEle,valueEle); lstSourceElmt.remove(NbEle); var elOptNew = document.createElement('option'); elOptNew.text = TxtEle; elOptNew.value = valueEle; lstCibleElmt.add(elOptNew); // COLOR THE OPTION (SAME COLOR AS THE RIGHT) lstCibleElmt.options[NbCible].style.backgroundColor = colors[userTypeElmt.selectedIndex]; /* if(userTypeElmt.selectedIndex==0){ lstCibleElmt.options[NbCible].style.backgroundColor='#f4f6e3';} if(userTypeElmt.selectedIndex==1){ lstCibleElmt.options[NbCible].style.backgroundColor='#75c1d1';} if(userTypeElmt.selectedIndex==2){ lstCibleElmt.options[NbCible].style.backgroundColor='#89d8b5';} if(userTypeElmt.selectedIndex==3){ lstCibleElmt.options[NbCible].style.backgroundColor='#33869c';} */ NbCible = NbCible + 1; NbSource = NbSource - 1; moved = moved +1; } } } } // ADD ALL function AjouterAll(){ var NbEle = -1; var TxtEle = ''; var valueEle=''; var lstSourceElmt = document.myForm.lstSource; var lstCibleElmt = document.myForm.lstCible; var userTypeElmt = document.myForm.userType; var longu=lstSourceElmt.length; for(var i = 0; i < longu; i++) { NbEle = 0; TxtEle = lstSourceElmt.options[0].text; valueEle = lstSourceElmt.options[0].value; if (NbSource != 0 && NbEle != -1){ addOption(lstSourceElmt.options[NbEle].value); // lstSourceElmt.options[NbEle] = null; // lstCibleElmt.options[NbCible] = new Option(TxtEle,valueEle); lstSourceElmt.remove(NbEle); var elOptNew = document.createElement('option'); elOptNew.text = TxtEle; elOptNew.value = valueEle; lstCibleElmt.add(elOptNew); // COLOR THE OPTION (SAME COLOR AS THE RIGHT) lstCibleElmt.options[NbCible].style.backgroundColor = colors[userTypeElmt.selectedIndex]; /* if(userTypeElmt.selectedIndex==0){ lstCibleElmt.options[NbCible].style.backgroundColor='#f4f6e3';} if(userTypeElmt.selectedIndex==1){ lstCibleElmt.options[NbCible].style.backgroundColor='#75c1d1';} if(userTypeElmt.selectedIndex==2){ lstCibleElmt.options[NbCible].style.backgroundColor='#89d8b5';} if(userTypeElmt.selectedIndex==3){ lstCibleElmt.options[NbCible].style.backgroundColor='#33869c';} */ NbCible = NbCible + 1; NbSource = NbSource - 1; } } } // REMOVE function Supprimer(){ var NbEle = -1; var TxtEle = '';var valueEle=''; var lstSourceElmt = document.myForm.lstSource; var lstCibleElmt = document.myForm.lstCible; var moved = 0; var longu= lstCibleElmt.length; for(var i = 0; i < longu; i++){ if (lstCibleElmt.options[(i - moved)].selected){ NbEle = i - moved; TxtEle = lstCibleElmt.options[(i - moved)].text; valueEle = lstCibleElmt.options[(i - moved)].value; if (NbCible != 0 && NbEle != -1){ delOption(lstCibleElmt.options[NbEle].value); // lstCibleElmt.options[NbEle] = null; // lstSourceElmt.options[NbSource] = new Option(TxtEle,valueEle); lstCibleElmt.remove(NbEle); var elOptNew = document.createElement('option'); elOptNew.text = TxtEle; elOptNew.value = valueEle; lstSourceElmt.add(elOptNew); NbCible = NbCible - 1; NbSource = NbSource + 1; moved = moved +1; } } } } // REMOVE ALL ELEMENTS function SupprimerAll(){ var NbEle = -1; var TxtEle = '';var valueEle=''; var lstSourceElmt = document.myForm.lstSource; var lstCibleElmt = document.myForm.lstCible; var longu = lstCibleElmt.length; for(i = 0; i < longu; i++){ NbEle = 0; TxtEle = lstCibleElmt.options[0].text; valueEle = lstCibleElmt.options[0].value; if (NbCible != 0 && NbEle != -1){ delOption(lstCibleElmt.options[NbEle].value); // lstCibleElmt.options[NbEle] = null; // lstSourceElmt.options[NbSource] = new Option(TxtEle,valueEle); lstCibleElmt.remove(NbEle); var elOptNew = document.createElement('option'); elOptNew.text = TxtEle; elOptNew.value = valueEle; lstSourceElmt.add(elOptNew); NbCible = NbCible - 1; NbSource = NbSource + 1; } } } function findIt(){ nom=document.myForm.searchName.value; matr=document.myForm.searchMatr.value; //if(nom!='')document.location.href='/MCIC/Init?choix=aportail&user='+nom; //else if(matr!='')document.location.href='/MCIC/Init?choix=aportail&id='+matr; //else alert('Veuillez remplir le nom ou matricule recherché');} document.location.href='/MCIC/Init?choix=aportail&user='+nom+'&id='+matr; } function loadIt(){ var selectedOne; var selectBox = document.myForm.userSelected; nom=document.myForm.searchName.value; matr=document.myForm.searchMatr.value; for(var i=0;i