4 Replies Latest reply: Jun 18, 2014 2:12 PM by Luke315 RSS

    PDF FORM - GPS INPUT

    Luke315 Community Member

      I am making a pdf form using acrobat XI on a mac (OS 10.6) and want to have a button to press that will input GPS co-ords into form fields, derived from the device (tablet, android, idevice)

       

      Someone else asked the same question in a forum, got the following javascript, and a number of people commented that it worked fine on all devices, and yet i get SyntaxError 4: line 5.

       

      Any ideas what i'm doing wrong?

       

      Code is:

       

      <script type="text/javascript">
      function getLocationConstant()
      {
        
      if(navigator.geolocation)
        
      {
        navigator
      .geolocation.getCurrentPosition(onGeoSuccess,onGeoError); 
        
      } else {
        alert
      ("Your browser or device doesn't support Geolocation");
        
      }
      }

      // If we have a successful location update
      function onGeoSuccess(event)
      {
        document
      .getElementById("Latitude").value =  event.coords.latitude;
        document
      .getElementById("Longitude").value = event.coords.longitude;

      }

      // If something has gone wrong with the geolocation request
      function onGeoError(event)
      {
        alert
      ("Error code " + event.code + ". " + event.message);
      }
      </script>

      <br><br>
      <cfform action="gps2.cfm" method="post">
      Latitude:
      <input type="text" id="Latitude" name="Latitude" value="">
      <br><br>
      Longitude:
      <input type="text" id="Longitude" name="Longitude" value="">
      <br><br>
      <input type="button" value="Get Location" onclick="getLocationConstant()"/>
      <br><br>
      <input type="submit" value="Add GPS Location" class=small>
      </cfform>




      I'm guessing it's some kind of XML issue but i have no program language experience at all !!!


      Thanks in advance