Hi everyone, I am doing my FYP and is stuck on this tiny portion on
the registration page. Currently, this google map already shows the
address on where ever I click. However it doesn't save the address
into the database through php.

I do not want users to manually type in their address as sometimes
they are not clear enough and google map might not find it. Thus
having them click on the map would be a better idea as google map will
provide the address. However I wanna do it in a way where once they
click on the map, the script would retrieve the address using
Javascript and update the HTML input text field without refreshing the
page. Something like a dynamic text field where users cannot edit
manually. Please help me =( Thanks..

Currently the code goes this way..



<html>  <head>
<title>Register</title>


    <script src="http://maps.google.com/maps?
file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-
m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
            type="text/javascript"></script>
    <script type="text/javascript">

    var map;
    var geocoder;
    var address;



    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(1.352083, 103.819836), 11);
      map.addControl(new GLargeMapControl);
      GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();
    }

    function getAddress(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }

    function showAddress(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Status Code:" + response.Status.code);
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(
        '<b>Address:</b>' + place.address);
         InitForm();
         return(location.address);

      }
    }


    </script>
  </head>

 <body onLoad="initialize()&&InitForm();" onreset="InitForm();">
<form action="p_Register.php" method="post">
<p>
<table border='0'>
<p>
<tr><td width="140"><u><strong>Account Information</strong></u></td>
</tr>

<tr><td>Preferred Username:</td><td width="147">
<input type="text" name="username" maxlength="60">
</td></tr>


<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>

<tr><td>Confirm Password:</td><td><input type="password" name="pass2"
maxlength="10"></td>
</tr>

<tr><td><u><strong>School Information</strong></u></td>
</tr>

<tr><td>Student ID:</td><td>
<input type="text" name="s_id" maxlength="60">
</td></tr>

<tr><td>School Email:</td><td>
<input type="text" name="s_email" maxlength="150">
</td></tr>

<tr><td><u><strong>Personal Information</strong></u></td>
</tr>

<tr><td>First Name:</td><td>
<input type="text" name="f_name" maxlength="60">
</td>

<td width="119">Last Name:</td>
<td width="229">
<input type="text" name="l_name" maxlength="60"></td></tr>


<tr><td>Date Of Birth:</td><td>
<input type="text" name="dob" maxlength="150">
</td></tr>

<tr><td>Telephone(Hm):</td><td>
<input type="text" name="hm_phone" maxlength="150">
</td>

<td>Telephone(Mobile):</td><td>
<input type="text" name="hp_phone" maxlength="150">
</td></tr>

<tr><td>Email:</td><td>
<input type="text" name="email" maxlength="150">
</td></tr>

<tr><td><p>Address:<br></p></td><td>
<input type="hidden" name="location" value="0"
onfocus="showAddress(response);">
<input name="address" disabled="disabled" type="text" value="0"
onfocus="showAddress(response);">

</tr>

<tr><td colspan="4">(Zoom in and click on the nearest <b>ROAD</b> to
your house)</td></tr>

<tr><td colspan="3">
  <div id="map_canvas" style="width: 500px; height: 400px"></div></
td></tr>


<tr><th colspan=2><input type="submit" name="submit"
value="Register"></th></tr>
 </table>
</form>

  </body>










--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to