<script>
function showPosition() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var latx = position.coords.latitude;
var lonx = position.coords.longitude;
var positionInfo = "(" + "Latitude: " + position.coords.latitude + ", " + "Longitude: " + position.coords.longitude + ")";
document.getElementById("result").innerHTML = positionInfo;
document.getElementById("latx") = latx;
document.getElementById("lonx") = lonx;
});
} else {
alert("Sorry, your browser does not support HTML5 geolocation.");
}
}
</script>
Blockquote Blockquote Blockquote
Я хочу, чтобы он отображался в моей форме в поле latxx и lonxx, но он не работает и даже не отображается, но отображается результат в div
<form action="addads.php" method="post" enctype="multipart/form-data">
<input class="kolo" type="text" name="ProTitle" placeholder="Title" alt="wating"
title="Pleaes write Your Title" require>
<textarea placeholder="Detalis" name="ProDetalis" id="my-input" class="form-control " rows="5"></textarea>
<input class="kolo" type="text" name="Proprice" placeholder="price" alt="wating" title="Pleaes write Your price"
require>
<div id="result">
<!--Position information will be inserted here-->
</div>
<input type="text" name="latxx" id="latxx" value=""/>
<input type="text" name="lonxx" id="lonxx" value=""/>
<button type="button" onclick="showPosition();">Show Position</button>
<input class="kolo" type="file" name="image">
<select class="kolo" name="Maincategory">
<?php
$resultcategories = mysqli_query($clink, "SELECT CategoryID , CategoryName FROM categories");
while ($rowcategories = mysqli_fetch_assoc($resultcategories)) {
echo "<option value='{$rowcategories['CategoryID']}'>{$rowcategories['CategoryName']} </option>";
}
?>
</select>
<input class="btn" type="submit" value="save">
</form>