Interaction Between Tables

Interaction Between Tables

Hello everyone and thanks for your help in advance.  I need to develop an application that has a page with a table of a customer's charges and payments made.  I'm trying to figure out how to click on a particular table row in payments and then click on a table row in charges that will in turn write back to a database to apply the payment to that particular charge line.  In turn the payment and charge lines will be recalculated.  I know this can be done, but I'm pretty stuck on how to get started.  I know I could put some type of checkbox within the payment table row.  Then when a checkbox in the charge table is clicked, it could start the update and recalculation process.  But I wonder if for example, the user clicks on a row in the charge table first, how can I handle that correctly.  I'm sure something like this has been created many times and I'm hoping someone can point me to some good examples or give me insight on best practices to create this.  Any help would be appreciated.