McCrum
McCrum

Reputation: 39

Adding Value into an Input Field

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://m.belfi.co.uk/form.html

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 :(

Upvotes: 0

Views: 423

Answers (1)

SLaks
SLaks

Reputation: 888205

You're looking for the val method:

$('input[name=Address]').val(function(index, oldVal) {
    return oldVal + ": " + lat + ", " + lon;
});

Upvotes: 2

Related Questions