View Full Version : Using javascript to guess the location.

07-10-2012, 09:21 PM
I am making a new site and require the user to select their location in the UK via a drop down menu. I was wondering if I could have them type it in and then Javascript using some sort of geoloction API bring up matches. For instance I may type "lon" and it would come up with "London" underneath the text box for me to select?

Thanks a bunch.

07-10-2012, 09:30 PM
there are tons of autocomplete scripts out there - google and see for yourself.

the problem is that you need to provide the script with the list of suggestions. if you are talking about every town in the uk that may be alot - you may want to look for one that you can hook up to an existing database of town names.

geolocation is when the script guesses the user's location without their input. this is possible in html5 (so IE<9 can't do it) and requires the user's permission.

the other possibility is an IP lookup, which is not so accurate, but at a city level in a place like the UK should be reasonably close

07-10-2012, 09:42 PM
I got one for countries which is nice. However, I need them for at least counties in the UK so I was thinking I could just download a list of counties and swap them with the countries?

07-10-2012, 09:50 PM
is there a question?

07-10-2012, 09:51 PM
I was wondering if it would work seen as the script was initially made for countries, but it does seem to be working.

Thank you for your help.