Advertisement
michaelyuen

Untitled

Dec 5th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Untitled Document</title>
  6.  
  7. <!-- Include plugin file -->
  8. <script
  9.   src="https://code.jquery.com/jquery-3.3.1.min.js"
  10.   integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  11.   crossorigin="anonymous"></script>
  12. <script src="https://getaddress.io/js/jquery.getAddress-2.0.8.min.js"></script>
  13. </head>
  14.  
  15. <body>
  16.     <!-- Postcode field -->
  17. <div id="postcode_lookup"></div>  
  18.  
  19. <!-- Add to your existing form -->
  20. <label>First Address Line</label>
  21. <input id="line1" type="text">
  22.  
  23. <label>Second Address Line</label>
  24. <input id="line2" type="text">  
  25.  
  26. <label>Third Address Line</label>
  27. <input id="line3" type="text">  
  28.  
  29. <label>Town</label>
  30. <input id="town" type="text">
  31.  
  32. <label>County</label>
  33. <input id="county" type="text">
  34.  
  35. <label>Postcode</label>
  36. <input id="postcode" type="text">
  37.                            
  38. <script>
  39. $('#postcode_lookup').getAddress({
  40.     api_key: '__replace_this_with_your_api_key',  
  41.     <!--  Or use your own endpoint - api_endpoint:https://your-web-site.com/getAddress, -->
  42.     output_fields:{
  43.         line_1: '#line1',
  44.         line_2: '#line2',
  45.         line_3: '#line3',
  46.         post_town: '#town',
  47.         county: '#county',
  48.         postcode: '#postcode'
  49.     },
  50. <!--  Optionally register callbacks at specific stages -->                                                                                                              
  51.     onLookupSuccess: function(data){/* Your custom code */},
  52.     onLookupError: function(){/* Your custom code */},
  53.     onAddressSelected: function(elem,index){/* Your custom code */}
  54. });
  55. </script>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement