Formidable support suggested I reach out here.
I am using the Premium Address Field option to capture International addresses, however the address gets stored in my custom field in an array format like this:
{"line1":"7 Chome-14-15 Ginza","city":"Chuo City","state":"Tokyo","zip":"104-0061","country":"Japan"}
I would like this stored in a more normal looking format like this:
7 Chome-14-15 Ginza Chuo City Tokyo 104-0061 Japan
Formidable support suggested that someone here might be able to help with a custom JavaScript function to extract each field in the address field and add that to a hidden field in my form.
Is there someone here that can help with this?
472 = Field ID of your address field
field_intl_address = field key of your address field
field_hidden_address = field key of your hidden field
You might want to include "line2" below. I only added "line1"
<script>
jQuery(document).ready(function($) { $("#frm_field_472_container").change(function() { const intl_address_field_prefix = 'field_intl_address_'; var streetAddress = $("#" + intl_address_field_prefix + "line1").val(); var city = $("#" + intl_address_field_prefix + "city").val(); var province = $("#" + intl_address_field_prefix + "state").val(); var postal = $("#" + intl_address_field_prefix + "zip").val(); var country = $("#" + intl_address_field_prefix + "country").val(); $("#field_hidden_address").val(streetAddress + " " + city + " " + province + " " + postal + " " + country); }); });
</script>
Thanks so much - I'll give this a try!
This code works great! Thanks!
Please login or Register to submit your answer