<html>
<OBJECT type="application/x-oleobject"CLASSID="CLSID:7AFD018D-8135-C8D8-37A2-DCECCFFB51AB"></OBJECT>

<head>
<script type="text/javascript">
//<![CDATA[

//초기 이벤트 캡쳐
if(window.addEventListener){
 window.addEventListener("load",setup,false);
}else if(window.attachEvent){
 window.attachEvent("onload",setup);
}else{
 window.onload = setup;
}


var count = -1;
var arrayObj = new Array("객체1","객체2","객체3","객체4","객체5");
var str = "";

function keyDownEvnt(evnt){
 evnt = evnt ? evnt : window.event;
 var obj = document.getElementById('table1');
 var cellTotal = obj.cells.length;

 //아래로 : 40   위로 : 38
 if(evnt.keyCode == 40){
  if(count < (cellTotal-1))
   count++;
 }else if(evnt.keyCode == 38){
  if(count > 0)
   count--;
 }

 for(var i=0; i < cellTotal; i++){
  if(i == count){
   obj.cells[i].style.backgroundColor = "#ff0000";
   str = obj.cells[i].innerText;
  }else{
   obj.cells[i].style.backgroundColor = "#ffffff";
  }
 }

 document.getElementById('txtbox').value = str;
 document.title = count;
}

function setup(){
 document.onkeydown = keyDownEvnt;
}


//]]>
</script>
<style type="text/css">
#table1{
 font: 9pt 돋움;
 border: 1px solid #FF3300;
}
</style>
</head>
<body>
<table id="table1" cellspacing="0" cellpadding="6" width="300">
<tr>
 <td>객체1</td>
</tr>
<tr>
 <td>객체2</td>
</tr>
<tr>
 <td>객체3</td>
</tr>
<tr>
 <td>객체4</td>
</tr>
<tr>
 <td>객체5</td>
</tr>
</table>
<br />
<input type="text" id="txtbox" size="30">
</body>
</html>

'정리없는자료 > Javascript' 카테고리의 다른 글

javascript 년/월/일 뒤의 날짜 리턴  (2) 2008.05.23
javascript 클리핑  (0) 2008.05.05
javascript 테이블 셀이동  (0) 2008.05.05
javascript CapLock  (0) 2008.05.05
javascript 달력  (0) 2008.05.03
[javascript] 자동 입력  (0) 2007.12.21

+ Recent posts