Not able to get rowId for dynamic table

Hi All,

I have few rows of data displayed in html table from sql query.
Now i need to retrieve rowIndex in javascript when click on row.

<td><input type=“button” id=“viewId” value=“View” onClick=“viewDetails(this);”></td>
<td ><input type=“text” id=“accountId” value=“<?php echo $accountNumb[$i];?>”></td>

function viewDetails(x)


This is giving me the same id for all the records.Can someone help me where i am going wrong…

Thanks in Advance.

please post the whole table structure as we see no information about the table row arrangement.