to get the index of the current row being edited with JavaScript, the following snippet works:
//replace Table1 with your variable name, and q10 with the column number for the one you want to watch from Table1.
$('li[attr="Table1"] table.cf-table tbody').on('change','td[data-col="q10"] input[name^="Field"]',function(){
//get the first parent table row
var row = $(this).closest('tr');
//get the 0-based index of the tbody that contains that row
var idx = $(this).closest('tbody').index(row);
});
Once you have that index, it depends whether you can assume that a row exists in Table 2 or not. If yes, then the snippet above would become:
//replace Table1 with your variable name, and q10 with the column number for the one you want to watch from Table1.
//replace Table2 with your variable name, and q20 with the column number for the one you want to set from Table2.
$('li[attr="Table1"] table.cf-table tbody').on('change','td[data-col="q10"] input[name^="Field"]',function(){
//get the first parent table row
var row = $(this).closest('tr');
//get the 0-based index of the tbody that contains that row
var idx = $(this).closest('tbody').index(row);
//set the other table's row's value
$('li[attr="Table2"] table.cf-table tbody tr').eq(idx).find('td[data-col="q20"] input[name^="Field"]').val($(this).val());
});
This gets a bit more complicated if you want the 2 tables to always match, even if a row is added/deleted from one or the other, but it is possible in JavaScript.