관리 메뉴

엉망진창

드래그로 체크박스 체크하기 본문

Study_Web/JS

드래그로 체크박스 체크하기

엉망진창 2008. 6. 30. 11:45
<form name="dragchkform" method="get">
<input type="checkbox" name="dragchk"> 체크박스 1<br>
<input type="checkbox" name="dragchk"> 체크박스 2<br>
<input type="checkbox" name="dragchk"> 체크박스 3<br>
<input type="checkbox" name="dragchk"> 체크박스 4<br>
<input type="checkbox" name="dragchk"> 체크박스 5<br>
<input type="checkbox" name="dragchk"> 체크박스 6<br>
<input type="checkbox" name="dragchk"> 체크박스 7<br>
<input type="checkbox" name="dragchk"> 체크박스 8<br>
<input type="checkbox" name="dragchk"> 체크박스 9<br>
<input type="checkbox" name="dragchk"> 체크박스 10<br>
</form>
<script language="javascript">
var dragchkstat = "off";
function dragchkNOOP() { return false; }
function dragchkOnMouseDown() {
        if (this.checked) {
                dragchkstat = "uncheck"; this.checked = false;
        } else {
                dragchkstat = "check"; this.checked = true;
        }
        return false;
}
function dragchkOnMouseOver() {
        switch (dragchkstat) {
                case "off":
                        break;
                case "check":
                        this.focus(); this.checked = true; break;
                case "uncheck":
                        this.focus(); this.checked = false; break;
        }
        return false;
}
function dragchkOnMouseUp() { dragchkstat = "off"; return true; }
for (i = 0; i < document.dragchkform.dragchk.length; i++) {
        document.dragchkform.dragchk[i].onclick = dragchkNOOP;
        document.dragchkform.dragchk[i].onmousedown = dragchkOnMouseDown;
        document.dragchkform.dragchk[i].onmouseover = dragchkOnMouseOver;
        document.onmouseup = dragchkOnMouseUp;
}
</script>

출처 : http://firejune.com/index.php?pl=99&ct1=8&ct2=42

'Study_Web > JS' 카테고리의 다른 글

웹사이트에 무료 FLVPlayer 달기  (2) 2009.08.12
드래그로 체크박스 체크하기 2  (0) 2008.06.30
문서 객체 모델(DOM)  (0) 2008.04.05
자바스크립트 이벤트 핸들러  (2) 2008.02.15
자바스크립트 onclick에서 return  (0) 2007.05.23