멀티플 셀렉트박스 이동, 정렬, multiple, selectbox, move, sort > script

본문 바로가기
사이트 내 전체검색

script

멀티플 셀렉트박스 이동, 정렬, multiple, selectbox, move, sort

페이지 정보

작성자 서방님 댓글 0건 조회 199회 작성일 10-02-22 14:31

본문

<html>
 <head>
  <script>
   function move(fbox,tbox){
    var arrFbox = new Array();
    var arrTbox = new Array();
    var arrLookup = new Array();
    //option의 value값을 바꿔주기위해 저장하는 배열

    for(i=0;i<tbox.options.length;i++){
     arrLookup[tbox.options[i].text] = tbox.options[i].value;
     //첨자로 'tbox.options[i].text' 가 왜 들어가는지 모르겠음...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     arrTbox[i] = tbox.options[i].text; //항목의 값.여기선 ASP,PHP,델파이 등
    }
    var fLength = 0;
    var tLength = arrTbox.length;

    for(i=0;i<fbox.options.length;i++){
     arrLookup[fbox.options[i].text] = fbox.options[i].value;
     if(fbox.options[i].selected && fbox.options[i].value != ""){
      arrTbox[tLength] = fbox.options[i].text;
      tLength++;
     }else{
      arrFbox[fLength] = fbox.options[i].text;
      fLength++;
     }
    }

    //리스트 항목 정렬
    arrFbox.sort();
    arrTbox.sort();


    //리스트의 option항목 개수를 0으로 초기화한다.
    fbox.length = 0;
    tbox.length = 0;

    //리스트에 항목 추가
    for(c=0;c<arrFbox.length;c++){
     var no = new Option();
     no.value = arrLookup[arrFbox[c]];
     no.text = arrFbox[c];
     fbox[c] = no;
    }
    for(c=0;c<arrTbox.length;c++){
     var no = new Option();
     no.value = arrLookup[arrTbox[c]];
     no.text = arrTbox[c];
     tbox[c] = no;
    }
   }
  </script>
 </head>
 <body>
  <form name="combo_box">
   <select multiple name="list1">
    <option value="1">ASP</option>
    <option value="2">PHP</option>
    <option value="3">델파이</option>
    <option value="4">JSP</option>
   </select>
   <input type="button" onClick="move(this.form.list2,this.form.list1)" value="◀"> <input type="button" onClick="move(this.form.list1,this.form.list2)" value="▶">
   <select multiple size="10" name="list2" style="width:150">
   </select>
  </form>
 </body>
</html>

댓글목록

등록된 댓글이 없습니다.

Total 846건 17 페이지
script 목록
번호 제목 글쓴이 조회 날짜
열람중 서방님 200 02-22
605 서방님 186 02-19
604 서방님 130 08-10
603
js 달력 댓글+ 2
서방님 77 08-10
602 서방님 116 08-10
601 서방님 153 07-29
600 서방님 128 07-21
599 서방님 203 07-06
598 서방님 115 06-04
597 서방님 198 05-28
596 서방님 101 04-20
595 서방님 177 04-15
594 서방님 198 04-10
593 서방님 166 03-13
592 서방님 158 03-10
게시물 검색

회원로그인

접속자집계

오늘
119
어제
225
최대
1,347
전체
154,878
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.