반응형
<script language="JavaScript">
document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
var tar = event.srcElement.form;
var Tindex = "";
if (window.event && window.event.keyCode == 40){
for(i=0;i<tar.elements.length;i++){
if(tar.elements[i] == event.srcElement) Tindex = i;
if(Tindex !== i && Tindex !== "" && tar.elements[i].type == "text"){
tar.elements[i].focus();
break;
}
}
}else if (window.event && window.event.keyCode == 38){
for(i= (tar.elements.length - 1);i>=0;i--){
if(tar.elements[i] == event.srcElement) Tindex = i;
if(Tindex !== i && Tindex !== "" && tar.elements[i].type == "text"){
tar.elements[i].focus();
break;
}
}
}
}
</script>
document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
var tar = event.srcElement.form;
var Tindex = "";
if (window.event && window.event.keyCode == 40){
for(i=0;i<tar.elements.length;i++){
if(tar.elements[i] == event.srcElement) Tindex = i;
if(Tindex !== i && Tindex !== "" && tar.elements[i].type == "text"){
tar.elements[i].focus();
break;
}
}
}else if (window.event && window.event.keyCode == 38){
for(i= (tar.elements.length - 1);i>=0;i--){
if(tar.elements[i] == event.srcElement) Tindex = i;
if(Tindex !== i && Tindex !== "" && tar.elements[i].type == "text"){
tar.elements[i].focus();
break;
}
}
}
}
</script>
반응형
'Story > Javascript' 카테고리의 다른 글
form 안의 text 상자를 화살표키로 이동하게 하기 (0) | 2009.01.19 |
---|---|
array 객체에 push 메소드가 정의 되지 않았다고 나올때 (0) | 2009.01.19 |
javascript convert HtmlEntities To Characters (0) | 2009.01.09 |
javascript convert unicode (0) | 2009.01.09 |
즐겨찾기 추가, 시작페이지로 (0) | 2008.12.17 |