Thanks for the comments and help. Sorry for not following the posting guidelines. I'll make sure to provide links for any other requests for help. Marcelo, the link on asynchronous definitely set me on the right path now. I've read through a portion of the econym tutorial in the past but hadn't read that section.
Best Wishes, Powell On Apr 21, 2:11 am, "[email protected]" <[email protected]> wrote: > On Apr 20, 7:21 pm, map_to_learn <[email protected]> wrote: > > > > > Hi, > > > I'm new to Google Maps API and don't do a lot of Javascript coding. > > I'm building a web app that lets users input an address into a form. > > I'm using an "onsubmit" to geocode the address and store the > > structured address, lat and lng in hidden fields and then passing them > > to a php script when submitted. The goal is to store the lat/lng in a > > user's profile when it's created to limit the number of geocoding > > calls. Another script will pull all of the users and display them on > > a map. > > > For some reason, the app is not able to pass the geocode data back to > > the hidden fields in the form unless I enable an alert in one of the > > javascript functions. Here is a code snippet. Can anyone give me > > some pointers on why turning on an alert in one of the functions makes > > it work but otherwise the data is not stored or passed to the php > > script? > > Sounds like you don't understand the asynchronous nature of > geocoding... > > > function InsertAddressLatLng(response) { > > if (!response || response.Status.code != 200) { > > alert("Sorry, there was an error geocoding your address"); > > } else { > > place = response.Placemark[0]; > > document.inputaddress.field_2.value = > > place.Point.coordinates[1]; > > document.inputaddress.field_3.value = > > place.Point.coordinates[0]; > > document.inputaddress.field_4.value = place.address; > > } > > } > > This looks like it should work... > > > > > > > function showLocation() { > > var address = document.inputaddress.field_1.value; > > geocoder.getLocations(address, InsertAddressLatLng); > > > //debugging alert statement- form works only when this is turned > > on. > > alert(address); > > } > > </script> > > > </head> > > > <body onload="initialize()" onunload="GUnload()"> > > > <form name="inputaddress" action="finished_test.php" > > onsubmit="showLocation();" > > This doesn't look like an API problem, but a general HTML form > submission problem. > > I suspect you need to return false here or the form will be submitted > before the results come back. > > You really should read the posting guidelines and post a link to your > map that exhibits your problem, not code. > > -- Larry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
