I am unsure exactly what you are trying to do, your post is somewhat unclear. But from what I can gather, you need to be more specific with your selectors.
For example: $( “td.gfield_list_1_cell5 input” ). That will select multiple rows because each row has a td.gfield_list_1_cell5 with an input in it.
You could do something like…
$(this).parent().find('.td.gfield_list_1_cell5 input').val( str );