<script language="
javascript">
/**
* 控制键盘的上下左右键的示例代码
* 编辑整理:www.jb200.com
* 2013/12/14
*/
<!--
//定义初始化行列
var currentLine=-1;
var currentCol=-1;
document.onkeydown=function(e){
e=window.event||e;
switch(e.keyCode){
case 37: //左键
currentCol--;
changeItem();
break;
case 38: //向上键
currentLine--;
changeItem();
break;
case 39: //右键
currentCol++;
changeItem();
break;
case 40: //向下键
currentLine++;
changeItem();
break;
default:
break;
}
}
//方向键调用
function changeItem(){
if(document.all)
var it=document.getElementByIdx_x("ice").children[0];
else
var it=document.getElementByIdx_x("ice");
for(i=0;i<it.rows.length;i++){
it.rows[i].className="";
}
if(currentLine<0){
currentLine=it.rows.length-1;
}
if(currentLine==it.rows.length){
currentLine=0;
} // www.jb200.com
var objtab=document.all.ice;
var objrow=objtab.rows[currentLine].getElementsByTagName_r("INPUT");
if(currentCol<0){
currentCol=objrow.length-1;
}else if(currentCol==objrow.length){
currentCol=0;
}
objrow[currentCol].select();
//调试使用
it.rows[currentLine].className="highlight";
}
//-->
</script>