Jump to content

Contact form address autofill?

Recommended Posts

For one of my client websites, the customer has requested an 'autofill' segment for addresses, based on location. I wondered if there were any existing plugins or any advice on how to do this in the squarespace form. I've strong familiarity with HTML and CSS, but not so much with Javascript and other languages.

I've come across this online, but I'm unsure if it can be implemented on Squarespace...https://www.solodev.com/blog/web-design/adding-an-auto-complete-address-field-to-your-forms.stml

Thanks in advance.

Edited by graphicpressryan
Initial Revision
Link to comment
  • 6 months later...
  • Replies 2
  • Views 2.8k
  • Created
  • Last Reply

Top Posters In This Topic

Hi @rjnicholds, GeoIP service technologies can help you access your visitors' locations based on their IPs.

When it comes to autofill segments for address regarding visitors' physical location, I would suggest GeoLocation API. The API reveals a visitor's country, state, and city with Javascript code and simple variables. You don't have to code yourself. Simply drag and drop Javascript they provided. It will auto-select drop downs and auto-populate form input boxes with location information. 

Please see sample code. Hope it helps!

geotargetly_country_name(); //gets visitor country name
geotargetly_country_code(); //gets visitor country code
geotargetly_region_name(); //gets visitor Region/State or state name
geotargetly_region_code(); //gets visitor Region/State or state code
geotargetly_city_name(); // gets visitor city name
geotargetly_lat(); // gets visitor latitude
geotargetly_lng(); // gets visitor longitude 
geotargetly_ip(); // gets visitor IP address

geotargetly_loaded(); // gets called when data is available


//----------------Example-------------

function geotargetly_loaded(){
  var country_name = geotargetly_country_name();
  if (country_name == "United States"){
      //do something
  }
}

 

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.