title: How can I pass JavaScript values to another PHP page using an HTML form?
body: <p>I have spent more than 2 months trying to solve this coding problem. First of all I know JavaScript runs on the client side and PHP runs on server.</p>
  
  <p>I have two PHP pages (index23.php and index24.php), both use HTML/PHP and JS.</p>
  
  <p>I'm using the HTML5 geolocation API:</p>
  
  <pre><code>&lt;body onload="getLocation()"&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  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= "+" + position.coords.latitude + "+" + position.coords.longitude;  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I can see the geocode values on my current PHP page (index23.php). Then I click an HTML form button and the browser goes to another page (index24.php).</p>
  
  <p>How can I pass the JavaScript values on the first PHP page to the second PHP page using the submit button on the form?</p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form id="searchbox" action="index24.php" method="get"&gt;
  &lt;input name="q" type="text" placeholder="Type here"/&gt;
  &lt;input id="submit" type="submit" value="Search"&gt;&lt;/form&gt;
  </code></pre>