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

  • Home
  • SEARCH
  • 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 7839221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:22:34+00:00 2026-06-02T15:22:34+00:00

I want to get the current GPS Location from the user’s device, and basically

  • 0

I want to get the current GPS Location from the user’s device, and basically drop Lat and Long into form fields. Then I can do whatever after inserting the location.

The code below works for a pop up alert location, which is what I started with. I want to be able to click a button and have it populate the long/lat into the form fields.

<html> 
<head> 


<script type="text/javascript"> 
function getLocationConstant()
{
  if(navigator.geolocation)
  {
    navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoFormLat,on GeoFormLong,onGeoError); 
  } else {
    alert("Your browser or device doesn't support Geolocation");
  }
}

// If we have a successful location update
function onGeoSuccess(event)
{
  alert(event.coords.latitude + ', ' + event.coords.longitude);
}

function onGeoFormLat(event)
{
  var myVal;
  myVal = document.getElementById(event.coords.latitude).value;
}

function onGeoFormLong(event)
{
  var myVal;
  myVal = document.getElementById(event.coords.longitude).value;
}

// If something has gone wrong with the geolocation request
function onGeoError(event)
{
  alert("Error code " + event.code + ". " + event.message);
}

// Called when we want to stop getting location updates
function stopGetLocation(event)
{
  navigator.geolocation.clearWatch(watchID); 
}

</script>


</head>
<body>
  <br><br>
  Latitude: <input type="text" id="Latitude" name="onGeoFormLat" value="">
  <br><br>
  Longitude: <input type="text" id="Longitude" name="onGeoFormLong" value="">
  <br>

  <br><br><br>
  <input type="button" value="Get Location" onclick="getLocationConstant()" />
  <br><br>

</body>
</html>
  • 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-06-02T15:22:37+00:00Added an answer on June 2, 2026 at 3:22 pm

    Friend of mine helped me out…
    This works gr8

     <script type="text/javascript"> 
     function getLocationConstant()
    {
        if(navigator.geolocation)
        {
            navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError);  
        } else {
            alert("Your browser or device doesn't support Geolocation");
        }
    }
    
    // If we have a successful location update
    function onGeoSuccess(event)
    {
        document.getElementById("Latitude").value =  event.coords.latitude; 
        document.getElementById("Longitude").value = event.coords.longitude;
    
    }
    
    // If something has gone wrong with the geolocation request
    function onGeoError(event)
    {
        alert("Error code " + event.code + ". " + event.message);
    }
     </script>
    
     <br><br>
     <cfform action="gps2.cfm" method="post">
     Latitude: <input type="text" id="Latitude" name="Latitude" value="">
     <br><br>
     Longitude: <input type="text" id="Longitude" name="Longitude" value="">
     <br><br>
     <input type="button" value="Get Location" onclick="getLocationConstant()"/>
     <br><br>
     <input type="submit" value="Add GPS Location" class=small>
     </cfform>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the current location of iPhone from GPS and Cellular network.
In my app i want to get the user current location through GPS and
I want to get zip code from users current location(Latitude, Longitude), I had used
I have a mapview where I want to track the user's current location. GPS
I want to get nearby cities from current location depending upon distance, e.g, cities
I want to get text from current active line (the line where the caret
I have my current location fixed via CoreLocation. Now I want to get those
i want to get the GPS coordinates from iphone and send these GPS coordinates
Possible Duplicate: How do I get the current GPS location programmatically in Android? I
In my application I want to get the location of the user and show

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.