Is it possible to extract individual fields from Autocompleted Address?

  • Profile Image
    Asked on May 18, 2017 at 11:17 AM

    If use the Autocompleted Address Widget it creates a set of sub-fields (for lack of a better name) such as 'Street name', 'House number', 'City', etc.

    I would like to extract the value from one of the fields (eg. city) to use in a conditional logic calculation. I am hoping there would be something similar to the Input Table where I can specify particular cell value.

    Just to be clear, I can see how it would be possible to create something like:

    "If 'Autocompleted Address' contains 'Chicago' then copy another field to another field"

    However, I want to be able to do something that requires me to extract the city value, like this:

    "If 'Autocompleted Address' is filled, copy value of 'City' to 'Hometown' field"

    One last detail. I can see how to do this by using the following logic:

    "If 'Autocompleted Address' contains 'Chicago' then calculate 'Hometown' equal to 'Chicago'"

    This would require me to create a crazy number of condition statements.

    Thanks in advance



  • Profile Image
    Answered on May 18, 2017 at 11:34 AM

    Yes this is possible.

    "If 'Autocompleted Address' contains 'Chicago' then copy another field to another field"

    So you want a condition that updates a field once another field is filled.

    The user guide has a relevant tutorial:

    How to Pass Field Value to Another Field?

  • Profile Image
    Answered on May 18, 2017 at 12:59 PM

    Unfortunately, the desired condition you're trying to achieve isn't possible with that widget. Since that widget is a group field, you can't extract a specific sub-field value out of it.

    The only workaround I know is to use a text area field but it would always copy the whole value.


    "If 'Autocompleted Address' is filled, copy value of 'Autocompleted Address' to 'Hometown' field"



  • Profile Image
    Answered on May 18, 2017 at 05:16 PM

    Apologies for the incorrect answer earlier. I should have tested it first.

    Just to follow up on Elton's post. I created a demo script that parses the "hometown" textarea. It actually extracts the city name.

    function myFunction(val) {
        var start = val.indexOf('City:');
        var end = val.indexOf('State:');
        var parsedString = val.substring(start, end);

    <textarea cols="50" rows="5" id="hometown" oninput="myFunction(this.value)">
    City: Rome
    State: Lazio
    Postal code: 00153
    Country: Italy


    Try copy/paste the code into a text editor, save it and open it with a browser.

    You can modify it to achieve what you want.

  • Profile Image
    Answered on July 19, 2017 at 07:17 PM

    I'm trying to use the above code to parse the autocompleted address but it's not working for me. Can you assist?

  • Profile Image
    Answered on July 19, 2017 at 09:04 PM

    The code given by @aubreybourke cannot be injected through the Form Builder since it does not accept JavaScript codes. You would need to get the form's source code in order to add the code. 


    Otherwise, will not be possible to separate the data entered in the widget and you would need to use the Address field instead.