9 Replies Latest reply: May 6, 2013 8:30 AM by jwellsnh RSS

    capturing a javascript result in an apex DML form

    Siberia
      Hi guys.
      i got a javascript that returns longitud and latitud , so i want to capture this data into 2 items in my DML form.
      any ideas ?
      thanks

      here is my javascript (i have added an "--" at the beginning just for this post):


      -- <!DOCTYPE html>
      -- <html>
      -- <body onunload="OnUnload()" onload="getLocation()">
      -- <a id="demo">Your coordinates: </a>
      -- <script>
      -- var watchID;
      -- var x=document.getElementById("demo");
      -- function getLocation()
      -- {
      -- if (navigator.geolocation)
      -- {
      -- var options = {maximumAge:600000, timeout:100000, enableHighAccuracy: true};
      -- watchID = navigator.geolocation.watchPosition(showPosition,showError,options);
      -- }
      -- else{x.innerHTML="Geolocation is not supported by this browser.";}
      -- }
      -- function showPosition(position)
      -- {
      -- x.innerHTML="[Latitude: " + position.coords.latitude + "] [Longitude: " + position.coords.longitude + "]";
      -- }
      -- function showError(error)
      -- {
      -- switch(error.code)
      -- {
      -- case error.PERMISSION_DENIED:
      -- x.innerHTML="User denied the request for Geolocation."
      -- break;
      -- case error.POSITION_UNAVAILABLE:
      -- x.innerHTML="Location information is unavailable."
      -- break;
      -- case error.TIMEOUT:
      -- x.innerHTML="The request to get user location timed out."
      -- break;
      -- case error.UNKNOWN_ERROR:
      -- x.innerHTML="An unknown error occurred."
      -- break;
      -- }
      -- }
      -- function OnUnload()
      -- {
      -- alert ("The current document will be unloaded!");
      -- navigator.geolocation.clearWatch(watchID);
      -- }
      -- </script>
      -- </body>
      -- </html>

      Edited by: Siberia on May 5, 2013 6:00 PM