단축키 이벤트

3337 단어 단축키
// 
document.onkeydown = keyDown;

function keyDown(e){
//	alert(window.event.keyCode);
	// 
	if (window.event.keyCode=="13"){
		 if(document.activeElement.id=="rideDate"){
			document.getElementById("purposeId").focus();
		}
		else if(document.activeElement.id=="purposeId"){
			document.getElementById("goStationId").focus();
		}else if(document.activeElement.id=="goStationId"){
           document.getElementById("queryButton").focus();
//            if($("hiddenTr").style.display == 'block'){ document.getElementById("idCode").focus();}
//			else{document.getElementById("fullTicketNum").focus();}
        }else if(document.activeElement.id=="idCode"){
            event.keyCode=9;
        }
        else if(document.activeElement.id=="idType"){
            event.keyCode=9;
        }
        else if(document.activeElement.id=="fullTicketNum"){
            event.keyCode=9;
        }else if(document.activeElement.id=="halfTicketNum"){
            event.keyCode=9;
        }else if(document.activeElement.id=="actualMoney"){
        	document.getElementById("completeButton").focus();
        	return false;
        }
        else if(document.activeElement.name=="rtOrderIds"){
        	 /******IE7 , ,IE8 ******/
        	 var radios = getElementsByName_iefix("rtorderGrid","input","type","radio");
             radios[(radios.length-1)].focus();
             /******************************/
             event.keyCode=9;
        }
    } 
    
    // 
    if (window.event.keyCode=="38"){
    	if(document.activeElement.name=="rtOrderIds"){
    		var index = (lastCheckRadioId.split("o")[1]);
    		
    		// , 
    		 if(index=='0'){
    			index = getElementsByName_iefix("rtorderGrid","input","type","radio").length-1;
    		}else{
    			index = index -1;
    		}
    		clickRow(index);
		}
    }
    // 
    if (window.event.keyCode=="40"){
    	if(document.activeElement.name=="rtOrderIds"){
			var index = parseInt(lastCheckRadioId.split("o")[1]);
			
    		// , 
    		 if(index == getElementsByName_iefix("rtorderGrid","input","type","radio").length-1){
    			index = 0;
    		}else{
    			index = index +1;
    		}
    		clickRow(index);
		}
    }
}

//getElementsByName IE7
function getElementsByName_iefix(div,tag,AttributeName,type) {
     var elem = document.getElementById(div).getElementsByTagName(tag);

     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute(AttributeName);
          if(att == type) {
              arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

좋은 웹페이지 즐겨찾기