멀티플 셀렉트박스 이동, 정렬, 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>
댓글목록
등록된 댓글이 없습니다.