Jump to content

oldinfo

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by oldinfo

  1. do not know how it works in all bowsers , but I think you mean in this: you mean a new tab in the same window
  2. Hi folks, as the lovely HTML5 coming and proving that it's an unbelievable language , I found the new technique "Geolocation" very helpful to my project. as a part of my project, I have a simple form gathering info from the user such as name , email andthe latitude and longitude of the user's position. In w3schools's example , the latitude and longitude are returned as normal text above each other :Latitude: 00.0000Longitude: 00.0000 ( not really zeros ) my question is: after clicking on a button (say get location) , the latitude and longitude coords will be automatically inserted (filled) into 2 input boxes ( visible or hidden ) to be sent to the database after submitting the Form . is it something to do with innerHTML ? how to do that ? <form action="handle_form.php" method="post"> <p>Name: <input type="text" name="name" size="20" /></p> <p>Email Address: <input type="text" name="email" size="20" /></p> <p id="demo">Click the button to get your coordinates:</p><button onclick="getLocation()">Try It</button><script>var x=document.getElementById("demo");function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else{x.innerHTML="Geolocation is not supported by this browser.";} }function showPosition(position) { x.innerHTML="Latitude: " + position.coords.latitude + "<br />Longitude: " + position.coords.longitude; }</script></form> the geolocation part code from here:http://www.w3schools...ml5_geolocation
×
×
  • Create New...