Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Row Number

Status
Not open for further replies.

pankajv

Programmer
Jan 30, 2002
178
IN
I have a table having multiple rows. Each row has a link. Is there any way by which I can get the row number in which a link is clicked?
 
There are several way to do it. Explain what exactly do you want to do.

One idea is this:
Put a hidden form field in some cell (one for each row) with some default value (like "0" for example).
When link is clicked, a JS function is activated that changes the hidden field value (fior example to "1").
Then you can loop through all hidden fields and check their values.
 
It is easy - because you generate all HTML and you can control what you generating... :)

you can put something like...
<table>
<tr><td><a href=&quot;javascript: alert('row 1'); wondow.location='some_address_1';&quot;>LINK</a></td></tr>
<tr><td><a href=&quot;javascript: alert('row 2'); wondow.location='some_address_2';&quot;>LINK</a></td></tr>
</table>
if you want process click on current page
or
if you want process click on next page...
<table>

-----------------------------
Sincerely,
Vlad Smachny
AlarIT Programmer
Web-development Dept.

<tr><td><a href=&quot;some_address_1?row=1&quot;>LINK</a></td></tr>
<tr><td><a href=&quot;some_address_1?row=2&quot;>LINK</a></td></tr>
</table>
 
let me give more details:
I have a table with some columns and one column has a link. On click of this link I have to display the details of the current row in a child window. For that I have called a Javascript function to which I have passed the row number which I have obtained by the loop counter when I am building the Table contents.
Till this point every thing is fine, But I have a reorder functionality also where a user can select a row and enter the row number where the selected row has to be moved. For that I have used the in built function moveRow().
By using this I am able to move the row to the entered position. Now since the innerHTML is copied for each row, I still Have the row number of the old row, so When I click on the Link it displays the contents of the old row rather than the row in which the link is clicked.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top