修改一下selectRow()函数,让返回一个object试试 

解决方案 »

  1.   


    <table onkeyup="ChangePage(this)" width="70%" border="1">
        <tr>
            <th>col1</th>
            <th>col2</th>
            <th>col3</th>
        </tr>
        <tr>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
    </table>
    <script >
    var currowno=0;
    var oldrowno=0;
    var oldColor="#eeeeee";
    var newColor="#ff0000";
    function ChangePage(table) 

        var KeyCode = event.keyCode;
        var len = table.rows.length;
        if (KeyCode == 38) 
        { 
          if(currowno>1) 
          { 
              if(oldrowno<len-1) 
              { 
                table.rows(oldrowno+1).style.backgroundColor=""; 
              } 
              table.rows(oldrowno).style.backgroundColor=oldColor; 
              
              currowno--; 
              if(currowno>0) 
              { 
                table.rows(currowno).style.backgroundColor=newColor; 
              } 
              oldrowno=currowno; 
          } 
          
        } 
        if (KeyCode == 40 ) 
        { 
          if(currowno <len-1) 
          { 
              if(oldrowno>0)
              {
                if(oldrowno>1)
                {
                    table.rows(oldrowno-1).style.backgroundColor="";
                }
                table.rows(oldrowno).style.backgroundColor=oldColor;
              }
              currowno++; 
              table.rows(currowno).style.backgroundColor=newColor; 
              oldrowno=currowno; 
          } 
          
        } 
       
    } </script>
      

  2.   

    <table onkeyup="ChangePage(this)" width="70%" border="1">
        <tr>
            <th>col1</th>
            <th>col2</th>
            <th>col3</th>
        </tr>
        <tr>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
        <tr>
            <td>11</td>
            <td>22</td>
            <td>33</td>
        </tr>
    </table>
    <script >
    var currowno=0;
    var oldrowno=0;
    var oldColor="#eeeeee";
    var newColor="#ff0000";
    function ChangePage(table) 

        var KeyCode = event.keyCode;
        var len = table.rows.length;
        if (KeyCode == 38) 
        { 
          if(currowno>1) 
          { 
              if(oldrowno<len-1) 
              { 
                table.rows(oldrowno+1).style.backgroundColor=""; 
              } 
              table.rows(oldrowno).style.backgroundColor=oldColor; 
              
              currowno--; 
              if(currowno>0) 
              { 
                table.rows(currowno).style.backgroundColor=newColor; 
              } 
              oldrowno=currowno; 
          } 
          
        } 
        if (KeyCode == 40 ) 
        { 
          if(currowno <len-1) 
          { 
              if(oldrowno>0)
              {
                if(oldrowno>1)
                {
                    table.rows(oldrowno-1).style.backgroundColor="";
                }
                table.rows(oldrowno).style.backgroundColor=oldColor;
              }
              currowno++; 
              table.rows(currowno).style.backgroundColor=newColor; 
              oldrowno=currowno; 
          } 
          
        } 
       
    } </script>
      

  3.   

        function ChangePage(KeyCode,url) 
        {         if (KeyCode == 38) 
            { 
              if(currowno>1) 
              {               if(table!=null && currowno>1 && oldrowno!=null) 
                  { 
                    table.rows(oldrowno).style.backgroundColor=oldColor; 
                  } 
                  currowno--; 
                  if(table!=null && currowno>0) 
                  { 
                    oldColor=table.rows(currowno).style.backgroundColor; 
                    table.rows(currowno).style.backgroundColor=newColor; 
                  } 
                  oldrowno=currowno; 
              } 
              
            } 
            if (KeyCode == 40 ) 
            { 
              if(currowno <table.rows.length-1) 
              { 
                  
                  if(table!=null && currowno <table.rows.length && oldrowno!=null && oldrowno <table.rows.length-1) 
                  { 
                    table.rows(oldrowno).style.backgroundColor=oldColor;; 
                  } 
                  currowno++; 
                  if(table!=null && currowno <table.rows.length) 
                  { 
                    oldColor=table.rows(currowno).style.backgroundColor; 
                    table.rows(currowno).style.backgroundColor=newColor; 
                  } 
                  oldrowno=currowno; 
              } 
              
            } 
            if (KeyCode == 13) 
            { 
              //打回车处理          
              //event.returnValue  =  false; 
              window.opener.location.href=../contractlr.aspx?id1=(        )&id2=(       );   
            } 
        } 比如括号的地方,要传两上参数过去,参数是表格当前的第一个单元格,和第二个单元格的值,应该怎么写呢/谢谢~
      

  4.   


    这个不行啊,怎样得到currowno行单元格的值啊?
      

  5.   

    表格currowno行单元格的第一个单元格:   table.rows(oldrowno).cell[0].innerHTML和第二个单元格的值:table.rows(oldrowno).cell[1].innerHTML