Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Autocomplete address, city name and street name using AJAX javascript

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i get the city and street name autocompleted in a form when someone fills the postcode and house number in a html form using AJAX.
Please help me out. I want the addresses only from the Netherlands. Many thanks in advance
 
Marshal
Posts: 25669
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The general outline of what you need to do in your JavaScript code is this:

1. You need to have some code which runs when it's clear that the postcode and house number fields have been completely filled in.

2. You need to use AJAX to send those two fields to a service somewhere which will return the related city and street names.

3. Upon receiving the AJAX response you need to extract the city and street names from it and put them into the appropriate fields.

That's just a general outline because your post didn't really discuss what problem you were having. Maybe you can't find a web service which deals with the Dutch addresses for you? Maybe you have no idea how to use AJAX? Could be anything. So let's start from there and see what questions you have based on that.
 
Abinn Gautam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response, I am a beginner in programming, I have an application form where users can fill their informations. All the other functions are working. But I also need to add auto completed city and street fields. And I don’t know where to start from. I have no idea about AJAX.
Thanks again
 
Saloon Keeper
Posts: 6506
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the backend exist already? Assuming so, do you know what its API is, meaning, what its inputs and outputs are?

I recommend to learn AJAX with a library like jQuery. https://learn.jquery.com/ajax/ and https://www.tutorialspoint.com/jquery/jquery-ajax.htm are some good starting points for that.
 
Abinn Gautam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the backend exists . I know a bit about API. And i also know that i need to get a api key inorder to use the api list.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use maps JavaScript API in your code it will help for the autocomplete of address,zip code ,state

for further details you follow this link

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic