4、用focus即可
5、见 http://expert.csdn.net/Expert/TopicView1.asp?id=2377985

解决方案 »

  1.   

    <table id="tab" onkeydown="keycheck()">
    <tr>
    <td><input></td>
    <td><input></td>
    <td><input></td>
    </tr>
    </table><script id="server" src="" onreadystatechange="server_return()"></script><script>
    function keycheck() {
      el = event.srcElement;
      if(event.keyCode == 13) {
        if(el.parentElement.cellIndex == 0)
          server.src = "服务器程序?k="+el.value; // 见要求
      }
    }
    server_mode = "";
    function server_return() {
      if(server_mode == "") return;
      el.parentElement.parentElement.cells[1].children[0].value = server_mode;
      el.parentElement.parentElement.cells[2].children[0].focus();  row = tab.lastChild.appendChild(tab.rows(tab.rows.length-1).cloneNode(true))
      for(i=0;i<row.cells.length;i++)
        row.cells[i].children[0].value = "";
    }
    </script>要求:
    服务器程序可以是任意语言,只要能做到:
    接受url参数,处理完毕后输出一行
    server_mode = "这里是查询结果";
      

  2.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>GetInfoFromDataBase</title>
    </head>
    <script>function addFun()//JK
    {
      var newRow = forAddTable.rows[0].cloneNode(true);
      var desRow = scoreTable.rows[scoreTable.rows.length-1];
      desRow.parentElement.insertBefore(newRow,desRow);
      scoreTable.rows[scoreTable.rows.length-2].all.studentNo.focus();
    }
    function deleteFun(deleteButton)//JK
    {  var documentCheckBox=document.getElementsByName("scoreID");
      if (confirm("Are you sure to delete?"))
      {
         scoreTable.deleteRow(deleteButton.parentElement.parentElement.rowIndex);
      }}function getTheStudentNameFun(studentNoInput)
    {
    var a=showModalDialog("GetStudentByNo.jsp?studentNo="+studentNoInput.value,"","status:no;resizable:no;help:no;dialogHeight:10px;dialogWidth:10px;");
    //if (a!=null)
    {
    studentNoInput.parentElement.parentElement.all.studentName.value=a;
    }
    }function keyDownControl()
    {
    k=event.keyCode;
    if(k==13)
    {
    event.keyCode=9;
    }}
    </script>
    <body><table width="100%" cellspacing="1" cellpadding="2" align="left" id="scoreTable"><tr >
        <td width=1 >&nbsp;</td>
        <td >No</td>
        <td >Name</td>
        <td >Score</td>
    </tr><tr >
        <td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
        <td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
        <td ><input name=studentName disabled></td>
        <td ><input name=studentScore onkeydown="keyDownControl();"></td>
    </tr>
    <tr><td><input type=button value=Add onclick="addFun();" ></td></tr>
    </table>
    <table id=forAddTable disabled style="display:none">
    <tr >
        <td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
        <td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
        <td ><input name=studentName disabled></td>
        <td ><input name=studentScore onkeydown="keyDownControl();"></td>
    </tr>
    </table>
    ------------------------------------- 
    GetStudentByNo.jsp: 
    <%String theStudentName="独孤求败";%><
    script language=javascript> window.returnValue='<%=theStudentName%>';
    window.close();
    </script></body></html>
      

  3.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>GetInfoFromDataBase</title>
    </head>
    <script>function addFun()//JK
    {
      var newRow = forAddTable.rows[0].cloneNode(true);
      var desRow = scoreTable.rows[scoreTable.rows.length-1];
      desRow.parentElement.insertBefore(newRow,desRow);
      scoreTable.rows[scoreTable.rows.length-2].all.studentNo.focus();
    }
    function deleteFun(deleteButton)//JK
    {  var documentCheckBox=document.getElementsByName("scoreID");
      if (confirm("Are you sure to delete?"))
      {
         scoreTable.deleteRow(deleteButton.parentElement.parentElement.rowIndex);
      }}function getTheStudentNameFun(studentNoInput)
    {
    var a=showModalDialog("GetStudentByNo.jsp?studentNo="+studentNoInput.value,"","status:no;resizable:no;help:no;dialogHeight:10px;dialogWidth:10px;");
    //if (a!=null)
    {
    studentNoInput.parentElement.parentElement.all.studentName.value=a;
    }
    }function keyDownControl()
    {
    k=event.keyCode;
    if(k==13)
    {
    event.keyCode=9;
    }}
    </script>
    <body><table width="100%" cellspacing="1" cellpadding="2" align="left" id="scoreTable"><tr >
        <td width=1 >&nbsp;</td>
        <td >No</td>
        <td >Name</td>
        <td >Score</td>
    </tr><tr >
        <td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
        <td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
        <td ><input name=studentName disabled></td>
        <td ><input name=studentScore onkeydown="keyDownControl();"></td>
    </tr>
    <tr><td><input type=button value=Add onclick="addFun();" ></td></tr>
    </table>
    <table id=forAddTable disabled style="display:none">
    <tr >
        <td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
        <td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
        <td ><input name=studentName disabled></td>
        <td ><input name=studentScore onkeydown="keyDownControl();"></td>
    </tr>
    </table></body></html>
    ------------------------------------- 
    GetStudentByNo.jsp: 
    <%String theStudentName="独孤求败";%><
    script language=javascript> window.returnValue='<%=theStudentName%>';
    window.close();
    </script>