的第一個PHP文件:如何在另一個(第二個)php文件中使用onsubmit函數?
<form onsubmit="showAddress(this.address.value); return false;" method="post" >
<h2>Enter Address</h2>
<input type="number" class=" typeahead large_inputbox" name="address" maxlength="6"/>
<input type="submit" value="Submit" class="submit" />
</form>
第二php文件:
function showAddress(address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
if (map.getZoom() < 16){map.setZoom(16);}else{}
marker.setPosition(results[0].geometry.location);
posset = 1;
computepos(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
如何使用的onsubmit功能在另一個(第二個)PHP文件?
你爲什麼要使用'的onsubmit()'在第二檔 – krishna
因爲showAddress參數值在Google地圖上選取地址..所以我使用showAddress函數.. – Logz