getLocation()
ページの読み込み時にこの関数を呼び出しています:
<script>
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition,showError);
}
}
function showPosition(position)
{
var latlon=position.coords.latitude+","+position.coords.longitude;
//alert("Your location: "+latlon);
document.getElementById("latitude").value = coords.latitude;
document.getElementById("longitude").value = coords.longitude;
}
function showError(error)
{
}
その後、HTML で 2 つの隠し値を定義しました。
<FORM id="myForm" action="insertar.php" method="post" enctype="multipart/form-data" data-ajax="false">
....Some other controls...
<input type="hidden" id="latitude" name="latitude" value="">
<input type="hidden" id="longitude" name="longitude" value="">
</FORM>
この関数では、2 つの非表示の値latitude
とlongitude
ユーザーの現在の場所を設定しています。しかし、PHP フォーム POST では、これら 2 つの値が渡されません。どうしたの?