multiple SelectBox 전체 선택, 해제 > script

본문 바로가기

script

multiple SelectBox 전체 선택, 해제

작성일 10-02-19 20:43

페이지 정보

작성자서방님 조회 778회 댓글 0건

본문

<select name="selectbox1" size="10" multiple>
 <option>aaa</option>
 <option>aaa</option>
 <option>aaa</option>
 <option>aaa</option>
 <option>aaa</option>
 <option>aaa</option>
 <option>aaa</option>
</select><br />

<input type="button" name="Button" value="All Check" onclick="selectAll('selectbox1',true)" />
<input type="button" name="Button" value="All UnCheck" onclick="selectAllUn('selectbox1',true)" />

<script language="javascript">
<!--
function selectAll(selectBox,selectAll) {
 // have we been passed an ID
 if (typeof selectBox == "string") {
  selectBox = document.getElementById(selectBox);
 }
 // is the select box a multiple select box?
 if (selectBox.type == "select-multiple") {
  for (var i = 0; i < selectBox.options.length; i++) {
   //selectBox.options[i].selected = selectAll;
   selectBox.options[i].selected = true;
  }
 }
}
function selectAllUn(selectBox,selectAll) {
 // have we been passed an ID
 if (typeof selectBox == "string") {
  selectBox = document.getElementById(selectBox);
 }
 // is the select box a multiple select box?
 if (selectBox.type == "select-multiple") {
  for (var i = 0; i < selectBox.options.length; i++) {
   selectBox.options[i].selected = false;
  }
 }
}
//-->
</script>

 

댓글목록

등록된 댓글이 없습니다.

전체 846건 17 페이지
게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기