You are viewing limited content. For full access, please sign in.

Question

Question

Forms: Auto-populate address fields via UK postcode (or US zip code) lookup

asked on March 12, 2015

If anyone has been able to automatically populate address fields on a Laserfiche form by undertaking a lookup of a UK postcode (or a US zip code) and the user selecting the relevant address from a dropdown option field can you please help me by explaining how this can be achieved.

0 0

Replies

replied on March 12, 2015

Hi John,

 

First you would need a database with all of the postcodes with addresses. This will be the hard bit but it seems you can get an online example here -

http://www.doogal.co.uk/files/postcodesMdb.zip 

 

Then you need to import this into a SQL database or an alternative ODBC provider and set this up as a DB look-up within the form. Pretty straight forward I suppose. Just a potentially massive DB it needs to perform the look-up on.

 

Hope this helps! yes

0 0
replied on August 24, 2015

John,

I was able to get the following code to work with Forms 9.2 but it appears that http://ziptasticapi.com only works with US zip codes.  You would need to find a similar API for UK postal codes.  A quick google search =https://postcodes.io/docs might do the trick.  

Zip code input class = zip

City class = city

State class = state

//Start Zip Code Lookup
$(document).ready(function () {
  $('.zip').change(function(){
    var zipCode = $('.zip input').val();
    
    var requestURL = 'http://ziptasticapi.com/' + zipCode + '?callback=?';
    $.getJSON(requestURL, null, function(data){
      console.log(data)
      
      if (data.city) $('.city input').val(data.city);
      if (data.state) $('.state input').val(data.state);
    });
  });
});
//End zip code lookup

Hope this helps!

Nate

0 0
replied on June 2, 2020 Show version history

Thanks for posting this. I tried to get it to work in my JavaScript window for a form in Laserfiche Forms. It couldn't read past the JSON call. Am I missing something? Gave the city, state, and zip class names to the appropriated input fields. Do I need to do anything to get LF Forms to read JSON?

This is what I see in the console window.

You are not allowed to follow up in this post.

Sign in to reply to this post.