title: how to get rowIndex when rows are created using DOM
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2545603/retrieve-table-row-index-of-current-row">Retrieve Table Row Index of Current Row</a>  </p>
  </blockquote>
  
  
  
  <pre><code>&lt;html&gt;
   &lt;script&gt;
   function addValue(a) {
  
        var element1  = document.createElement('tr');
        var element2 = document.createElement('td');
        var text = document.createTextNode(a);
        var table  = document.getElementById('t');
        element2.appendChild(text);
        element1.appendChild(element2);
        table.tBodies(0).appendChild(element1);
      }
  &lt;/script&gt;
  Name: &lt;input type="text" name="a"&gt;
  &lt;input type="button" value="Add" onClick='javascript:addValue(a.value)'&gt;
  &lt;table id="t" border="1"&gt;
  &lt;tr&gt;&lt;th&gt;Employee Name&lt;/th&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>this is my code sample, now when user click on any row how can i get the rowIndex</p>