List Field - Target jQuery one row at a time [RESOLVED]

Hi all!
So my question is, how to target one Row at a time within the List Field when using jQuery? I am working on this jQuery which will eventually populate fields from the Parent field (Features) to the Children fields (Description, address, etc.) within a List Field. I have been able to get the fields to populate in a certain column, but when I change the first row parent, it changes the children field in all the rows.

You can see an idea of what I am working on here: https://goadrifttravel.com/00-test/

Also this is the code I have been working with to make it happen:

jQuery(document).ready(function($) {
// START Place Jquery in here
		$( "select" ).change(function() {
		$(this).parent().click(function() {
	  var str = "";
$( "td.gfield_list_1_cell4 option:selected" ).each(function() {
  str += $( this ).text() + " ";
});
$( "td.gfield_list_1_cell5 input" ).val( str );
})
.trigger( "change" );
});	
});

So… any thoughts on how to target one Row at a time within the List Field with jQuery? I’ve been trying the each() function, but so far no luck. I’ve also been playing with the parent(), and closest(), but I am still very new to jQuery and might not be doing it right.

Thanks!

UPDATE
With the following code, I can now assign a custom/random class HOWEVER, it is assigning it to all future

's as well. I want one for the first row, and a different one for the second, etc:
	$("tr").one( "click", function(){
	var random = Math.floor(Math.random() * 1000);
	$(this).addClass("row" + random);
	});

Any idea’s why it is only letting me affect the first row, and not the following ones? It also does this with my population

Solved it!!! Boy it was tough. Gravity Forms Support gave me some help, but really it was trial and error, and sleep! Here is the answer in case anyone is interested:

jQuery(document).ready(function($) {
	$("tr").live("change", function popstuff() {
		var str = "";
		$("td.gfield_list_1_cell4 select option:selected").each(function() {
			str = $( this ).text();
			$(this).closest("tr").find(".gfield_list_1_cell5 input").val( str );
		});
	})

	.trigger( "click" );
gform.addAction( 'gform_list_post_item_add', function ( item, container ) {
    popstuff();				
} );
});
1 Like

Thank you for sharing the solution!

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.