i am trying to get to modify this script .
i have a form that returns the longditude and latitude from google map api.
I am trying to insert that data into a new form. With a lot of uyahoogling i made some progress but canyt nail this down or find clear directions where im going wrong.

so the original code is

  g.geocode(address, function(data) {
        if(data != null) {
          olat = data.latitude;
          olng = data.longitude;

 $('#geocode-result').append("Latitude: " + olat + "<br />" + "Longitude: " + olng + "<br /><br />");

thats is fine that it appends to a div
so my modification is

    type: 'text',
    id: 'geocode-long', 
    value: olng

    type: 'text',
    id: 'geocode-lat', 
    value: olat

this kinda works but i want this to enter into a new form , not the existing form but i cannot find how to specify that. its frustrating but oi really cant find a reference to do that, im assuning its in the append to form but not sure how to be more specific.

2 Years
Discussion Span
Last Post by DaveAmour

Change }).appendTo('form'); to instead of 'form' to be something more specific

Eg #formid if the other form has an id.

Does the other form already exist or are you creating it on the fly?


i think it would be better to use an existing , this seems to create on the fly though


Some additional info. When you select someting in jquery, you are using the same selectors used in CSS.

If you do this $("p").append("XXXXXXXXXXXXXXXXXXXXXX")

then this will append to all paragraph tags. If there was just one p tag then it would just do the one. In your page you may only have one form? You need to be more specific in your selector - ie <p id="32">Test</p> to select just this paragraph use $("#32") - # means id.

You can easily experiment with jquery to test things in any page whch uses jquery.

Daniweb does so if you are using IE then hit F12. Then click on the console tab. Then at the bottom type in $("p").append("XXXXXXXXXXXXXXXXXXXXXX") and hit return or maybe type in $("p").hide().

This is a great way to experiment with jquery.

So tip - to improve your jquery skills, study CSS!

Edited by DaveAmour: typo


thanks for c;larifying that, i got it. i got bogged down with the choices i think. :)


strangest thing is i see the form fields but they donot appear in the page source or if i print_r ($_post) i am not getting the data so csomething seekms amiss


View source depending on the browser and how you are viewing the source may show you the source when the page was loaded or it may be a real time representation. Its is usually best to use the built in developer tools for the browser. This is usually arrived at by F12.

Which browser are you using?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.