SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Javascript variables to php...how?

    Dear all,

    I need help...

    I'm creating a small app where the user can upload a photo and also mark the location of the photo on a google map. I would then like the longitude and latitude to be stored in mysql-db via a PHP-script. I'm fairly good a PHP/Mysql but a newbie in the area of Javascript and google-map API.

    The page has a map and the user is able to search for a location and drag the marker to the exact location. The user then adds text-information in a number of text-fields.

    After the location is marked and the text-information is added the user clicks "submit". I would then like the text-info and the longitude and latitude to be send to the the same PHP-file and inserted into the DB. I'm stuck and would very much appriciate all the help I can get... should I do it via hidden fields and $_GET?

    The map is working as it should and as long as I get the variables (longitude and latitude) to the PHP-page I will be able to sort it out.


    /nimrod

  2. #2
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you not have long and lat hidden fields in the form being submitted.
    Add a callback (on the drag action that places the marker) to update the fields with those values, then when it is submitted the values are in the form?

    It's over 6 months since I played with GMaps API, but from what I remember that sounds quite possible.

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks,

    how do I write the callback?

    This is the code that plots the marker.

    (tried to post the entire code but got an errormsg about links and spam)

    // ====== Plot a marker after positive reponse to "did you mean" ======
    function place(lat,lng) {
    var point = new GLatLng(lat,lng);
    map.setCenter(point,12);
    map.addOverlay( new GMarker ( point, {draggable: true} ) );
    document.getElementById("message").innerHTML = "";
    }

  4. #4
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is difficult to point you at the docs when I'm not allowed to post links :P

    Look in
    code DOT google DOT com
    apis
    maps
    documentation
    reference DOT html

    Gmarker

    dragend and getpoint


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •