1

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:

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" );
}); 
});

Any thoughts on how to target one jQuery Row at a time within the List Field? I've been trying the each() function, but so far no luck.

0

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 );
| improve this answer | |
  • I played with the parent(), but I haven't tried the find(). I'll give that a go! – Parkbum Dec 18 '18 at 23:35
0

Solved it!!! Boy it was tough. The find() definitely helped! Gravity Forms Support gave me some help, but really it as trial and error, and a good night of 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();             
} );
});
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.