HTML5 Geolocation, JavaScript, and Storing in Database
<p>The following code is JavaScript in a JSP. I want to store the user’s latitude and longitude locations in a MySQL database by setting the value of two hidden fields on the HTML (called “latitude” and “longitude”). However, when the parameters "latitude" and "longitude" are sent to the database, they are null! Why doesn’t this code work? Any help would be greatly appreciated!</p>

<pre><code>//in my onSubmit() JavaScript function 
latitude = position.coords.latitude;
longitude = position.coords.longitude;
document.getElementById("latitude").value = String(latitude);
document.getElementById("longitude").value = String(longitude);
document.getElementById("study_session_form").action = "CreateStudySessionServlet";
document.getElementById("study_session_form").submit();

//in my HTML
&lt;td&gt;&lt;input type="hidden" id="latitude" /&gt;&lt;/td&gt;                   
&lt;td&gt;&lt;input type="hidden" id="longitude" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;button id="submit_button” onclick="onSubmit();"&gt;Submit&lt;/button&gt;&lt;/td&gt;
</code></pre>
