'좌우이동'에 해당되는 글 1건

  1. 2010.04.01 [Javascript] 메뉴 좌우이동

왼쪽 메뉴를 선택해서 오른쪽 메뉴로 옮길 때

function selectClick(){
 var idx = basicInfoForm.shopName.length;
 var opt = basicInfoForm.shopName.options;
 
 for(var i=0; i<basicInfoForm.unselect.length; i++){
  if(basicInfoForm.unselect.options[i].selected==true){
   if(idx>0){
    for(var j=0; j<idx; j++){
     if(basicInfoForm.unselect.options[i].text==basicInfoForm.shopName.options[j].text){
      alert('이미 선택한 shop입니다.');
      return ;
     }else{
      basicInfoForm.shopName.length += 1;
      opt[idx] = new Option(basicInfoForm.unselect.options[i].text, basicInfoForm.unselect.options[i].value);
      basicInfoForm.unselect.options[i] = '';
      i -= 1;
     }
    }
   }else{
    basicInfoForm.shopName.length += 1;
    opt[idx] = new Option(basicInfoForm.unselect.options[i].text, basicInfoForm.unselect.options[i].value);
    basicInfoForm.unselect.options[i] = '';
    i -= 1;
   }
  }
 }
}

function unSelectClick(){
 var idx = basicInfoForm.unselect.length;
 var idx2 = basicInfoForm.shopName.length;
 
 if(idx2==null||idx2==''){
  alert('선택한 shop이 없습니다.');
  return ;
 }
 
 for(var i=0; i<idx2; i++){
  if(basicInfoForm.shopName.options[i].selected==true){
   basicInfoForm.shopName.options[i] = null;
   idx2 -= 1;
   i -= 1;
  }
 }
}

Posted by zeide
,