Click to See Complete Forum and Search --> : Detect last row made


bulgarian388
09-24-2006, 04:37 PM
Hi all, I have an asp.net page that is built on the fly through JavaScript depending on the link pressed in the nav menu. One of those links is a search by last name letter (A,B,C,etc.). When that is pressed an iFrame talks to another asp.net page that checks the database and returns the results to the page via a parent.function(). That works all fine, I return the results and build my results table with the createElement() and appendChild() functions. The problem is that I also need to give each row its own result number, i.e. 1,2,3,4,5,6... How do I do that with the JavaScript that build the result rows? Any help would be appreciated. If need be, I will post the JavaScript for all to see.

Thanks in advance,
Alex

Fang
09-25-2006, 02:08 AM
Check the rowIndex for the table row:<table border="1" cellpadding="0" cellspacing="0" summary="rowIndex example">
<tbody>
<tr onclick="alert(this.rowIndex)"><td>row 0</td></tr>
<tr onclick="alert(this.rowIndex)"><td>row 1</td></tr>
</tbody>
</table>

bulgarian388
09-25-2006, 12:04 PM
Thanks in advance Fang, but it was a no go. I put the this.rowIndex as the innerHTML of the column that is supposed to have the numbers, but it displayed "undefined". Then I tried applying it as an attribute to the row via setAttribute("onClick", "alert(this.rowIndex)") and obviously when you click it it alerts you, but the result is identical for each row. It returns a -1. Could it be the fact that the page is generated by JavaScript and there isn't any "hard coded" HTML?

Thanks again,
Alex