Jump to content

form value help


jmr3460

Recommended Posts

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.

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.