+ Start a Discussion

How to pass a value from Javascript to apex:inputfield


We have a Google Maps app on our VisualForce page. We have a little window that opens up when you click on the map and shows the latittude and longitude. We also have a button on the window. When you click the button we want to send the lattitude and longitude to two different apex:inputfields on the visualforce page to populate them and then you can save the record. The only problem we are having is moving the lattitude and longitude from the javascript to the apex:inputfield. 

We are trying to do the document.getElementById('LatInput').value = LatFromMap;

where LatInput is our apex:inputfield and LatFromMap is the var in javascript that holds the lattitude.

It let us do it using a regular html input tag but it will not with the apex:inputfield.

Is there a way to do this? 

thanks in advance!
This is because the id you give the component gets a bunch of additional information prepended to it to make it unique on the page.  There's more information at: