jmr3460 Posted April 9, 2011 Share Posted April 9, 2011 Hello all, I do not do very much Javascript at all. I am basically trying to create a var and insert it either into a hidden form field or a input text field. I am working on a script that gets the GPS location of my Blackberry from my Blackberry. It will be a way for me to log in and out of jobs during the day. I have research the blackberry site and been able to develop a script that get my coordinates and send them to an alert window. This script works great. I have attempted to do this by changing the 'window.alert' to 'document.write' and make a var (I did not get something wright their or for some reason this did not work. I think that this issue is that it takes several seconds to retrieve the coordinates). I was hoping to be pointed to a way that I could insert those alert values into the form fields when I click the alert ok button or maybe when I click the ok button that creates the variables. Can anyone help me with this? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <script type="text/javascript"> <!-- function latlng(){ if(blackberry.location.GPSSupported){ document.write("Your device supports GPS lacating"); blackberry.location.onLocationUpdate(window.alert("Latitude: " + blackberry.location.latitude + " Longitude: " + blackberry.location.longitude)); blackberry.location.refreshLocation(); } else{ document.write("Your device does not support GPS"); } } --> </script> <head> <title>Blackberry GPS Logger</title> </head> <body onLoad="latlng()"> </body> </html> This is what I have so far. Still researching. Quote Link to comment https://forums.phpfreaks.com/topic/233233-form-value-help/ Share on other sites More sharing options...
jmr3460 Posted April 10, 2011 Author Share Posted April 10, 2011 I have now found a confirm box. Problem now is that when I click Ok nothing happens. Here is the new code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <script type="text/javascript"> <!-- function latlng(){ if(blackberry.location.GPSSupported){ document.write("Your device supports GPS lacating"); var long = blackberry.location.onLocationUpdate(window.confirm("Latitude: " + blackberry.location.latitude + " Longitude: " + blackberry.location.longitude)); blackberry.location.refreshLocation(); if (long){ window.location = "http://www.abc.org" } else{ alert("Nothing happened") } } else{ document.write("Your device does not support GPS"); } } --> </script> <head> <title>GPS Testing</title> </head> <body onLoad="latlng();"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/233233-form-value-help/#findComment-1199495 Share on other sites More sharing options...
jmr3460 Posted April 10, 2011 Author Share Posted April 10, 2011 Is the syntax right with this statement: var long = blackberry.location.onLocationUpdate(window.confirm('GPS coordinates good')); Quote Link to comment https://forums.phpfreaks.com/topic/233233-form-value-help/#findComment-1199516 Share on other sites More sharing options...
jmr3460 Posted April 10, 2011 Author Share Posted April 10, 2011 How about this one? var lat = blackberry.location.latitude; Or this one? var lng = blackberry.location.longitude; I can't get either one of these to write on my phone. Quote Link to comment https://forums.phpfreaks.com/topic/233233-form-value-help/#findComment-1199521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.