Dynamic Table with dynamic links

Problem- Each input has a table. Each table has variable rows and each row contain a link.

Example- Suppose we have 3 inputs resulting 3 tables comprising of 6, 13, 4 rows respectively.

What is required- put 1st input generating 1st table, count the rows and click on link in the 1st row , it shall popup the new window, store values from that window and then come to 2nd row…nth row. when completed …put 2nd input…nth input

Please suggest me what to do