Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:05:14+00:00 2026-05-26T01:05:14+00:00

Hi is there anyway using Javascript to get user’s current location and autocomplete fields

  • 0

Hi is there anyway using Javascript to get user’s current location and autocomplete fields in a form like telephone country code (e.g. in Singapore it is +65) and area code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:05:15+00:00Added an answer on May 26, 2026 at 1:05 am

    It’s really difficult, and I’d advise against it because it’s loads of effort for very little reward. The best way (most fluid for the user) would be to get the users IP using PHP/ASP/Ruby-on-Rails/whatever and query one of the freely available Geo-IP databases (Google it) to match that to a country, then create your own database of country codes (using this, or similar).

    If you really really want to do it using JavaScript, it’ll only let you do it in newer browsers, and it’ll prompt the user that you want to know their location… a lot of people will wonder why you’re asking for this and click no.

    // first, check it's supported
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(insertCountryCode);
    }
    

    insertCountryCode is a function that you pass. Why? Because the prompt for the user to allow your website to know their location is non-modal, meaning the page will carry on running while it waits for a response, so the function when they do respond will be asynchronous (outside the normal flow). This function is where you look up their location and insert their country code. In this function, use the Google Maps API and pass the latlng parameter to get the country… then you need to find another lookup service which will let you find out the dialing code.

    The reason I’ve explained this is to show you how hard it is. A much simpler alternative would be to have a drop-down box with

    <option value="+65">Singapore</option>
    

    and insert the value into the phone number box. That’s what I advise you do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to grab the referring URL using javascript, lets say the reffering
I'd like to do the same in C#. Is there anyway of using properties
Is there anyway, using google analytics, to track a user's journey/selections through a long
Is there anyway using the ITask interface to communicate with a scheduled task? I
Is there anyway to restrict by using pre-processing directives to prevent a project from
Is there anyway to create C# spelling checker without using Office library? I would
I am using python unit test module. I am wondering is there anyway to
I have a question regarding using Semaphores HANDLE WINAPI CreateSemaphore(...); Is there anyway I
Just curious if there is anyway to display an objects retain count using NSLog.
Is there any way to get the name of all installed fonts on user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.