Hello, In this post we will learn how to create autocomplete textbox field with places (Country, City, State) in php. For this purpose we will use google API Â and autocomplete script. Code is below…Lets see how to do..
|
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html> Â Â Â <html> Â Â Â Â Â <head> Â Â Â Â Â Â Â <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> Â Â Â Â Â Â Â <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script> Â Â Â Â Â Â Â <script> Â Â Â Â Â Â Â Â Â Â Â var autocomplete; Â Â Â Â Â Â Â Â Â Â Â function initialize() { Â Â Â Â Â Â Â Â Â Â Â Â Â autocomplete = new google.maps.places.Autocomplete( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /** @type {HTMLInputElement} */(document.getElementById('autocomplete')), Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { types: ['geocode'] }); Â Â Â Â Â Â Â Â Â Â Â Â Â google.maps.event.addListener(autocomplete, 'place_changed', function() { Â Â Â Â Â Â Â Â Â Â Â Â Â }); Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â </script> Â Â Â Â Â </head> Â Â Â Â Â <body onload="initialize()"> Â Â Â Â Â Â Â <div id="locationField"> Â Â Â Â Â Â Â Â Â <input id="autocomplete" placeholder="Enter your address" onFocus="geolocate()" type="text"></input> Â Â Â Â Â Â Â </div> Â Â Â Â Â </body> Â Â Â </html> |
