title: Getting the Row index of a table on onkeypress
body: <p>How can I get the row index of a table on keypress</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type="text" onkeypress="test(this)"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr onclick="test2(this)"&gt;
      &lt;td&gt;Click to show rowIndex&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr onclick="test2(this)"&gt;
      &lt;td&gt;Click to show rowIndex&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;script&gt;
  function test(x)
  {
   alert("Row index is: " + x.rowIndex);
  }
  function test2(x) {
      alert("Row index is: " + x.rowIndex);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>i am confused as test2 returns the row but test one shows undefined.
  Any explanation as to why it returns undefined and the proper way to get the index would be greatly appreciated.</p>