value
Sets or gets the value of the address input.
Description
The value of an address input is an object of type Address
.
The Address
object's data will differ depending on the site visitor's input method:
- Site visitor enters free text in the address input: Only the
Address.formatted
property will contain data. - Site visitor selects one of the Google address suggestions: The
Address.formatted
property and all relevantAddress
properties that correspond to the selected Google address will contain data.
You cannot modify the value
object in-place. To change the value
of an address input, do the following:
- Store the
value
object's data in a variable. - Make changes to the object.
- Reset the
value
property with the modified object.
Notes:
If an address input is connected to a dataset, setting the address input's
value
in code does not set the value of the connected field in the dataset. That means if you use the dataset to perform a submit, the value changed in code is not reflected in the submitted item.To submit the new value using a dataset, set the field's value using the
setFieldValue()
function before performing the submit.
Type:
NAME
TYPE
DESCRIPTION
Address in human-readable format. The formatted address is displayed in the address input element.
Address coordinates.
Address street name and number.
Address city.
Address subdivision of a country, such as a state or province.
Address country.
Address postal code.
Was this helpful?
1let address = $w("#myAddressInput").value;23/* {4 * "formatted":"500 Terry A Francois Blvd, San Francisco, CA 94158, USA",5 * "location": {6 * "latitude": 37.7703718,7 * "longitude": -122.387124799999988 * },9 * "streetAddress": {10 * "name": "Terry A Francois Blvd",11 * "number": "500"12 * },13 * "city": "SF",14 * "subdivision": "CA",15 * "country": "US",16 * "postalCode": "94158"17 * }18 */
1let address =2 {3 "formatted":"500 Terry A Francois Blvd, San Francisco, CA 94158, USA",4 "location": {5 "latitude": 37.7703718,6 "longitude": -122.387124799999987 },8 "streetAddress": {9 "name": "Terry A Francois Blvd",10 "number": "500"11 },12 "city": "SF",13 "subdivision": "CA",14 "country": "US",15 "postalCode": "94158"16 }1718$w("#myAddressInput").value = address;
1let address =2 {3 "formatted": "500 Terry A Francois Blvd, San Francisco, CA 94158, USA"4 }56$w("#myAddressInput").value = address;
This example retrieves the value of an address input, adds a postal code to the address, and then overwrites the old value.
1let address = $w("#myAddressInput").value;2address.postalCode = "94158";3$w("#myAddressInput").value = address;4