开发者

transfer javascript var into html form textbox

开发者 https://www.devze.com 2023-01-26 17:07 出处:网络
Hi i have click event that will pop up a info window & marker each time a click is detected on the map.

Hi i have click event that will pop up a info window & marker each time a click is detected on the map.

In the infowindow, i am trying to display the lat and lng as soon as the click is completed. i manage to get the event.latlng, but how to transfer the location.lat(), or location.lng() into the html text box?

Thanks

google.maps.开发者_如何学Pythonevent.addListener(map, 'click', function(event) { 
placeMarker(event.latLng);
 });

 function placeMarker(location) {

var html = "Add a reminder:" + "<form id='remindForm' onsubmit='return false;' />" + "Latitude: <INPUT id='test' TYPE='TEXT' NAME='lat' VALUE='' SIZE='25' MAXLENGTH='50' disabled='disabled'><br />" + "Longtitude: <INPUT TYPE='TEXT' NAME='lng' VALUE='' SIZE='25' MAXLENGTH='50' disabled='disabled'><br />" + "<textarea id='remindBox' style='width: 250px; height: 40px'></textarea><br />" + "<input type='button' value='Submit' onclick='submitBlog()'></form>"; if ( remindMarker ) { remindMarker.setPosition(location); } else { remindMarker = new google.maps.Marker({ position: location, map: map }); } infoWindow.setContent(html); infoWindow.open(map, remindMarker); document.getElementById(test).value=location.lat(); }


document.getElementById('test').value=location.lat();

test is not a variable, it is a string.

0

精彩评论

暂无评论...
验证码 换一张
取 消