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 8772051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:56:41+00:00 2026-06-13T17:56:41+00:00

This is the code I’m working from: http://jsfiddle.net/njDvn/36/ The weird thing is, the autosuggest

  • 0

This is the code I’m working from:

http://jsfiddle.net/njDvn/36/

The weird thing is, the autosuggest only seems to activate on the last input box after I click on the geocode button. This is the code im working from:

<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script>
function getLatLng() {
    var geocoder = new google.maps.Geocoder();
    var address = document.getElementById('address').value;

    var input = document.getElementById('searchTextField');
    var options = {
    types: [],
    };

var autocomplete = new google.maps.places.Autocomplete(input, options);

    geocoder.geocode({
        'address': address
    }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var latLng = results[0].geometry.location;
            $('#lat').val(results[0].geometry.location.lat());
            $('#lng').val(results[0].geometry.location.lng());
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
}
</script>
</head>
    <body>
        <div>
            <input id="address" type="textbox" value="Sydney, NSW">
            <input type="button" value="Geocode" onclick="getLatLng()">
            <input id="lat" type="textbox" value="lat">
            <input id="lng" type="textbox" value="lng">
            <input id="searchTextField" type="text" size="50" value="">

           </div>
      </body>
</html>

​What gives? I’ve never had this before, but this is the first script I have tried to put together.

  • 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-13T17:56:43+00:00Added an answer on June 13, 2026 at 5:56 pm

    This is due to the following line:

    var autocomplete = new google.maps.places.Autocomplete(input, options);
    

    input links it to:

    var input = document.getElementById('searchTextField');
    

    which is the last input box.

    In addition, you have to click on the geocode button before Google autocomplete links because you have bound the getLatLng() call to the click of the Geocode button:

    <input type="button" value="Geocode" onclick="getLatLng()">
    

    Because the Google autocomplete activates from within this function, you cannot initialize it without pressing the button.

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

Sidebar

Related Questions

This code : http://jsfiddle.net/bYtTG/1/ Works as I want in FF, chrome and opera, but
This code does not seem to run well: http://jsfiddle.net/5GEru/1/ var left = 0; function
This code is working now. LogCat only for lead back problems from other ppl
This code comes from: http://code.activestate.com/recipes/577090-file-encryption-using-stream-cipher/ import sys import random if len(sys.argv) != 4: print
This code only renders a dodecahedron and completely ignores the glBegin(GL_TRIANGLES) block: glutSolidDodecahedron(); glBegin(GL_TRIANGLES);
This code in the ERB only displays one image. I thought it would be
This code is from Apple's WWDC 2011 Session 318 - iOS Performance in Depth
This code will submit the information from the form to a php file, everything
This code is reading from mysql db tables and should return few names. But
This code can be used to select the first ten records from a table

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.