Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Is there a free auto-complete model for adresses ? And if yes, what is it ?

Explorer ,
Jul 31, 2023 Jul 31, 2023

Hi. 

So I'm working on a form for my job, and my superior has asked me to find a way to generate the right city and the right postal code based on an address. So I've heard that Google Maps offer this kind of auto-complete option, but it's not free (we're a small business). Is there a free way to do it, maybe with JavaScript ?

Thank you.

TOPICS
How to , JavaScript , PDF forms
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Aug 17, 2023 Aug 17, 2023

You can use this as 'Validation' script of "Address" field:

var city = this.getField("City");
var postal = this.getField("Postal code");

if(event.value == "Address1"){
city.value = "City1";
postal.value = "Postal code1";}

else if(event.value == "Address2"){
city.value = "City2";
postal.value = "Postal code2";}

else if(event.value == "Address3"){
city.value = "City3";
postal.value = "Postal code3";}

//add more 'else if' if needed

else{
city.value = "";
postal.value = "";}

Just change field names to your actual field names.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2023 Nov 10, 2023
LATEST

You need to use or (||) for multiple strings, like this:

if (event.value === "Walmart Inc." || event.value === "Walmart" || event.value === "walmart")

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2023 Aug 01, 2023

Are you talking about JS in a PDF file, or in a web-page? Because this forum is about the former.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 01, 2023 Aug 01, 2023

In a PDF file

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2023 Aug 01, 2023

In that case then no, unless you embed the entire address DB into your file...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 17, 2023 Aug 17, 2023

How would that be possible ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 17, 2023 Aug 17, 2023

I only need a small number of adresses, and I have them all in a document.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2023 Aug 17, 2023

You can use this as 'Validation' script of "Address" field:

var city = this.getField("City");
var postal = this.getField("Postal code");

if(event.value == "Address1"){
city.value = "City1";
postal.value = "Postal code1";}

else if(event.value == "Address2"){
city.value = "City2";
postal.value = "Postal code2";}

else if(event.value == "Address3"){
city.value = "City3";
postal.value = "Postal code3";}

//add more 'else if' if needed

else{
city.value = "";
postal.value = "";}

Just change field names to your actual field names.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 17, 2023 Aug 17, 2023

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 10, 2023 Nov 10, 2023

Hi, I have a little problem with the code. When I write the subsequent adresses with "else if", it completes the city and postal code field with the correspondant answer of the first adress. When I only write "If" for every adresses, it automatically fill the correspondant city and postal code fields with the last adress data. How to solve this problem ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2023 Nov 10, 2023

Post the script you tried or the actual file (with script inside).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 10, 2023 Nov 10, 2023
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2023 Nov 10, 2023
LATEST

You need to use or (||) for multiple strings, like this:

if (event.value === "Walmart Inc." || event.value === "Walmart" || event.value === "walmart")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines