我使用以下内容更新递送邮政编码的纬度和经度。
代码运行良好,除非调用脚本时它会从输入框中删除邮政编码。
有人能告诉我这是为什么吗?
<script type="text/javascript">
//<![CDATA[
var geo = new GClientGeocoder();
function getAddress(search) {
geo.getLocations(search, function (result)
{
if (result.Status.code == G_GEO_SUCCESS) {
var p = result.Placemark[0].Point.coordinates;
var lat=p[1];
var lng=p[0];
var dcMessage = '<span style="color:#990000">Post Code Successfully GeoCoded</span>'
var dcHiddenOutput = '<input type="hidden" name="lat" value="' +lat+ '"><input type="hidden" name="lng" value="' +lng+ '">';
document.getElementById("ConfirmOrder").innerHTML += dcMessage;
document.getElementById("UpdateGeo").innerHTML += dcHiddenOutput;
}
}
);
}
function theNext() {
var addresses = document.getElementById("myInput").value;
getAddress(addresses);
}
//]]>
</script>
<form id="UpdateGeo" method="get" action="updateGeocode.asp">
<input id="myInput" name="PostCode" style="text-transform:uppercase" />
<input type="checkbox" onClick="theNext()">
<input type="submit" value="Update Database">
</form>