I have a google map that has a marker which is dragged. When I get the new latitude and longitude coordinates, I need to put them into an HTML form as hidden fields.
How can I do that? The example page with current code is here: http://www.comehike.com/outdoors/parks/add_trailhead.php
如果您的表单已经包含隐藏的输入字段,并且这些字段具有ID,则可以执行
document.getElementById("id of the input field").value = myVariable;
Add these to your form (if they dont exist):
<input type="hidden" value="" id="lat" name="lat" />
<input type="hidden" value="" id="lng" name="lng" />
Then once you want to update the values just do:
document.getElementById("lat").setAttribute("value", newLat);
document.getElementById("lng").setAttribute("value", newLng);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.