Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Using javascript to guess the location.

    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.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    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

  • #3
    New Coder
    Join Date
    Jul 2012
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    is there a question?

  • #5
    New Coder
    Join Date
    Jul 2012
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

    Mandex


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •