0
我有一个文本字段,用户应该输入一个地址。点击搜索按钮后,将执行一个函数,该函数使用该地址来查找附近的POI。这很好。但是,当用户点击返回键时,文本字段的值不保存在变量中。这导致搜索被执行地址变量的旧值。输入文本不能保存按下输入的值
我甚至都不明白为什么它使它有所不同,说实话。
HTML
<form action="" method="post">
<input type="text" class="innenfeld" id="addressInput" name="addressInput">
<input type="button" class="send" onclick="newsearch()"/>
</form>
的JavaScript
function newsearch() {
var address = document.getElementById("addressInput").value;
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
searchLocationsNear(results[0].geometry.location);
} else {
alert(address + ' not found');
}
});
}
通过这种方式,他可以扣型'submit'和不'onclick'事件被写入像'' – morgul
哇,这让我有些灰白的头发。多谢你们。 – 5mark