【发布时间】:2017-01-27 19:01:28
【问题描述】:
我有以下代码在拖动标记时更新页面上的 latbox/lngbox“表单字段”值:
<!---Code the Address & Lat/Long into the Info window --->
function codeAddress() {
var address = document.getElementById('address').value;
var account = document.getElementById('account').value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
if (marker) {
marker.setMap(null);
if (infowindow) infowindow.close();
}
marker = new google.maps.Marker({
map: map,
draggable: true,
position: results[0].geometry.location
});
google.maps.event.addListener(marker, 'dragend', function() {
// updateMarkerStatus('Drag ended');
geocodePosition(marker.getPosition());
});
google.maps.event.addListener(marker, 'dragend', function (event) {
document.getElementById("latbox").value = this.getPosition().lat();
document.getElementById("lngbox").value = this.getPosition().lng();
});
问题:如何将这两个值“传递”到下面的网址?
<!---Create the page to display the Account Name, Address, Geocode button to update page & Save button to save Lat/Long back into Salesforce --->
<div>
<div align="center">
<form action="" method="get">
<input name="account" type="hidden" id="account" value="<cfoutput>#URL.id1#</cfoutput>">
<input name="address" type="hidden" id="address" value="<cfoutput>#URL.id2#</cfoutput>">
<input type="button" value="Plot this customer using Physical Address" Title="Click to Map the Physical Address of Salesforce Account (if avl)"onclick="codeAddress()">
New Latitude: <input size="20" type="text" id="latbox" name="lat" >
New Longitude: <input size="20" type="text" id="lngbox" name="lng" >
<input type="button" name="updateAccountLatLng" id="updateAccountLatLng" value="Update Account?" onclick="window.location.href='https://www.mysalesforce.com/001U000000W2Xgx/e?<cfoutput>#URL.id1#</cfoutput>&00NU0000003BKlJ=javascript.latbox&00NU0000003BKlO=javascript.lngbox'">
</form>
</div>
我可以让 JavaScript 值动态显示在我的表单字段/页面中,但我无法让 JavaScript 值传递到 URL 字符串中?
【问题讨论】:
-
丹,当单击 updateAccountLatLng“按钮”时,我正在尝试将 lat 和 lng 值传递到 url。 (见 /form 正上方的代码行)
-
如果你现有的代码正在填充表单字段,并且表单有method =“get”,这不是提交表单的简单事情吗?
标签: javascript coldfusion