Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

UK Post Code Search

$
0
0
Hi All
I am looking for a way I can add this into my sites table, so when we add a new site address, we can use a post code lookup

Would anybody have any idea where I can insert this to pick up the Postcode form my table please?

Thanks
Paul.

$('#submit').click(function(){  

  //Get Postcode
  var number = $('#number').val();
  var postcode = $('#postcode').val().toUpperCase();;

  //Get latitude & longitude
  $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=' + postcode + '&sensor=false', function(data) {

    var lat = data.results[0].geometry.location.lat;
    var lng = data.results[0].geometry.location.lng;

    //Get address    
    $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + lng + '&sensor=false', function(data) {              
      var address = data.results[0].address_components;              
      var street = address[1].long_name;
      var town = address[2].long_name;
      var county = address[3].long_name;                        

      //Insert
      $('#text').text(number + ', ' + street + ', ' + town + ', ' + county + ', ' + postcode);

    });
  });
});

Viewing all articles
Browse latest Browse all 2586

Trending Articles