views:

42

answers:

1

Hey, I am working on an iPhone Web App using HTML & CSS. I have currently got the JavaScript/HTML5 Geolocation picking up my current location and showing me it on a Google Map using Lat & Long values. I also want to add these Lat & Long Values into the 'address' text field on the page so I can submit the details.

Here is the link: http://j.mp/asSzvT

When I click 'find me' I would like the lat and long to be added to the 'address' input field. Have no idea how to do this though :(

+2  A: 

You're looking for the val method:

$('input[name=Address]').val(function(index, oldVal) {
    return oldVal + ": " + lat + ", " + lon;
});
SLaks
Didn't seem to work :(
McCrum
@McCrum: You'll need to place it inside your `showMap` function, below the lines where you set the values of `lat` and `lon`. Exactly where you have the call to `alert` will work nicely.
Ken Browning
Worked a treat, thanks guys :-)
McCrum
Then you should accept this answer by clicking the hollow check.
SLaks