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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:09:51+00:00 2026-05-22T23:09:51+00:00

I have a form which collects a persons address. When they click submit I

  • 0

I have a form which collects a persons address. When they click submit I want to geocode their address, and use that to fill lat and lng fields. Here is what I am doing now which is based on the 2nd answer here submit form does not stop in jquery ajax call

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var geocoder;
        var address;
        $('#theform').submit(function() {
            geocoder = new google.maps.Geocoder();
            address = $('#id_street').val() + " " + $('#id_street2').val() + " " + $('#id_city').val() + ", " + $('#id_state').val() + " " + $('#id_zip').val();
            geocoder.geocode( { 'address': address}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                $('#id_lat').val(results[0].geometry.location.lat().toFixed(6));
                $('#id_lng').val(results[0].geometry.location.lng().toFixed(6));
                $('#theform').unbind('submit');
                $('#theform').submit();
              } else {
                $('#theform').unbind('submit');
                $('#theform').submit();
              }
            });
            return false;
        });
    });
</script>

and the form

<form method="POST" id="theform" action="">
    <li><label for="id_street">Street</label> <input id="id_street" type="text" name="street" value="3520 Lebon Dr." maxlength="100" /></li>
    <li><label for="id_street2">Street2 (optional)</label> <input id="id_street2" type="text" name="street2" maxlength="100" /></li>
    <li><label for="id_city">City</label> <input id="id_city" type="text" name="city" value="San Diego" maxlength="50" /></li>
    <li><label for="id_state">State</label> <select name="state" id="id_state">
    ...a bunch of state options...
    <li><label for="id_zip">Zip Code</label> <input id="id_zip" type="text" name="zip" value="92122" maxlength="30" /></li>
    <label for="id_lat">Latitude</label><input type="text" name="lat" value="0.000000" id="id_lat" />
    <label for="id_lng">Longitude</label><input type="text" name="lng" value="0.000000" id="id_lng" />
</form>

The lat and lng fields get filled fine, but the form does not actually get submitted by $(‘#theform’).submit(). To actually submit the form you have to click submit again.

Any ideas about what I am doing wrong?
And in case anyone asks I do want to submit the form even if geocoding is unsuccessful as in that case I will be using geopy to geocode the address server side.

edit:
Ok so I made a really simple example and can’t get submit to work at all:

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

<script type="text/javascript">
$(function() {
    $('#subby').click(function() {
        $('#theform').submit();
    });
});

</script>

</head>
<body>
<a href="#" id="subby">Submit</a>
<form id="#theform" action="javascript:alert('success!');">
      <input type="submit" />
</form>
</body>
</html>

I would expect that when clicking the link Submit you would get an alertbox just like when you click the submit button, but this is not the case. What am I doing wrong with submit?

  • 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-22T23:09:52+00:00Added an answer on May 22, 2026 at 11:09 pm

    I just figured it out. I accidentally omitted my submit button from the form I posted. It was named submit. Apparently that mucks things up for jquery (thanks here: jQuery doesn't submit a form). The simple example I posted still isn’t working and I’m not sure why but my actual problem is solved.

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

Sidebar

Related Questions

I have a form that collects information, one piece of which is a phone
I have a form which users must fill out and submit. The controller action
I have a form which collects user info including name, location, url, email address
I have a form which has only tab control in it. I want to
I have a form which users can add controls to and when they right
I have an online form which collects member(s) information and stores it into a
I have an online form which collects consumer data and stores in a dedicated
I have a form which collects a name, password and email_address which are all
I am very new to PHP; ADD.PHP - I have a form that collects
I have a multidimentional array that is generated by: $('#order-submit').click(function(){ var orderResult = [];

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.