先幫我解決按向上鍵怎么使光標向上的問題。
我現在能用下面的代碼使光標在自動生成的几行input里向下跳﹕
function init(){
   var ta=document.all.abcde;
   for(var i=0;i<100;i++){
 if(document.getElementById("abcde"+i)!=null) {
     document.getElementById("abcde"+i).onkeydown=function (){    
  if(event.keyCode == 40){
     var textid=Number(this.id.substring(5,this.id.length))+1;
     if(textid<100) document.getElementById("abcde"+textid).focus(); }
         }  }  }   }
請問怎么使按向上鍵時光標向上跳﹖

解决方案 »

  1.   

    //var textid=Number(this.id.substring(5,this.id.length))+1;
    var textid=Number(this.id.substring(5,this.id.length))-1;//你把这个改成-1就上跳了嘛
    if(textid>=0) document.getElementById("abcde"+textid).focus
      

  2.   

    function init(){
       var ta=document.all.abcde;   
       for(var i=0;i<100;i++){
     if(document.getElementById("abcde"+i)!=null) {
         document.getElementById("abcde"+i).onkeydown=function (){    
      if(event.keyCode == 40){
         var textid=Number(this.id.substring(5,this.id.length))+1;
         if(textid<100) document.getElementById("abcde"+textid).focus(); }
             }  }   }
       for(var j=100;j>=0;j--){
     if(document.getElementById("abcde"+j)!=null) {
         document.getElementById("abcde"+j).onkeydown=function (){    
      if(event.keyCode == 38){
         var textid2=Number(this.id.substring(5,this.id.length))-1;
         if(textid2>=0) document.getElementById("abcde"+textid2).focus(); }
         }  }   } 
    }
    這樣寫為何只能向上跑﹐不能向下跑了。
      

  3.   

    if(event.keyCode == 40){
         var textid=Number(this.id.substring(5,this.id.length))+1;
         if(textid<100) document.getElementById("abcde"+textid).focus(); }
      if(event.keyCode == 38){
         var textid2=Number(this.id.substring(5,this.id.length))-1;
         if(textid2>=0) document.getElementById("abcde"+textid2).focus(); }
             }  }   }   }
    哦﹐改為這樣就可以了﹐謝。怎么使提交后得到的頁面的某一input默認得到光標焦點﹖
      

  4.   

    現在有個init()的js函數處理從abcde0開始往下跳﹐但在文件后面用<script language="JavaScript">   
    /*form2.abcde0.focus();*/
    document.all.abcde0.focus();
    </script>不能設默認焦點了。 
      

  5.   

    document.all.inputnamex.focus();放在</form>后面。
    如果可用普通頁面實現功能就不需用框架去弄。