You are viewing limited content. For full access, please sign in.

Question

Question

populate an address table and have it automatically populate another address table?

asked on August 29, 2014

 I am looking to get one address table that has been populated to automatically sends the same info to another address table in the same form.  What is the best way to achieve this?  Thanks.

 

*The field ID for the main address is q65 and secondary address field ID is q212

 

 

0 0

Answer

SELECTED ANSWER
replied on August 29, 2014 Show version history

If you don't mind the second field updating as the first field is updated, this will do it:

 

$(document).ready(function () {
    $('.check').change(function () {
        var firstAddress = $('.addressOne').find('input');
        var secondAddress = $('.addressTwo').find('input');

        for (i = 0; i < 6; i++) {
            $(secondAddress[i]).val($(firstAddress[i]).val());
        }

    });
});

There might be an issue if the other address field is hidden, because those fields will be disabled.

1 0

Replies

replied on August 29, 2014

You can do it just about the same way shown in my answer to this post.

0 0
replied on August 29, 2014

Eric,

 

Is it possible to set this up once the first address has been populated, without relying on a checkbox? thanks.

 

$(document).ready(function () {
    $('.check').change(function () {
        var firstAddress = $('.addressOne').find('input');
        var secondAddress = $('.addressTwo').find('input');
        if ($(this).find('input[value="Yes"]').is(':checked')) {
            for (i = 0; i < 6; i++) {
                $(secondAddress[i]).val($(firstAddress[i]).val());
            }
        }
        else {
            secondAddress.val('');
        }
    });
});


 

0 0
SELECTED ANSWER
replied on August 29, 2014 Show version history

If you don't mind the second field updating as the first field is updated, this will do it:

 

$(document).ready(function () {
    $('.check').change(function () {
        var firstAddress = $('.addressOne').find('input');
        var secondAddress = $('.addressTwo').find('input');

        for (i = 0; i < 6; i++) {
            $(secondAddress[i]).val($(firstAddress[i]).val());
        }

    });
});

There might be an issue if the other address field is hidden, because those fields will be disabled.

1 0
replied on August 29, 2014

instead of the .addressOne or .addressTwo, could I use the ID of the fields instead? ie. q65?

0 0
replied on August 29, 2014

Sure, just remember to use a hash instead of a period in your selector. #q65 not .q65.

0 0
replied on August 29, 2014

Thanks!  I ended up modifying the code to get it to work for two other address fields within the same form.

 

$(document).ready(function () {
    $('#q65').change(function () {
        var firstAddress = $('.addressOne').find('input');
        var secondAddress = $('.addressTwo').find('input');
  var thirdAddress = $('.addressThree').find('input');
        for (i = 0; i < 6; i++) {
            $(secondAddress[i]).val($(firstAddress[i]).val());
           $(thirdAddress[i]).val($(firstAddress[i]).val());
        }

    });
});

 

0 0
replied on August 29, 2014

You're welcome!

0 0
replied on November 12, 2020

This can also be done within a calculation in the field itself.  I used the information in the post below to populate the mailing address with the business address if they were the same. 

https://answers.laserfiche.com/questions/120123/Radio-button-copy-content-of-fields

Christine

0 0
replied on August 29, 2014

#Field65_DSG0 = Street Address

#Field65_DSG1 = Address Line 2

#Field65_DSG2 = City

#Field65_DSG3 = State / Province / Region

#Field65_DSG4 = Postal / Zip Code

#Field65_DSG5 = Country

 

If you use those with some Javascript whenever the first address field is modified, you can use the references to store the values into the corresponding fields for the secondary Address field.. You will just need to change the field number to the field number of the new address field when referencing the various sections

0 1
You are not allowed to follow up in this post.

Sign in to reply to this post.