You need to sign in to do that
Don't have an account?
Display value from Javascript to field in module Contact
Dears
I would like to know how to display a value in any field of my form Contact. I get the value from a JavaScript function after that I need to send the value and dislay in the field Phone Number (example) module Contact.
Below the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<script type="text/javascript">
function test(){
var abc;
//this part of the code work but is not what I want.
document.getElementById("lat").value= abc --> "Value get form another Javascript function";
// I want to display the value of "var abc" in the field phone numbe rof module contact
}
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="map_canvas" style="width: 700px; height: 400px">
<input name="lat" id="lat" type="text" readOnly="true" />
<!-- Display info -->
</div>
</body>
</html>
do you mean the Contacts in sfdc? Then you have to make this a Visualforce page first. In that page, you can reference the sfdc objects like Account, Contact, etc. Then you can think about modifying field per Javascript. Right now you don't have any sfdc object in your page that you could update.
Just in case you haven't found the documentation yet, below are the links.
Visualforce Developer's Guide
http://www.salesforce.com/us/developer/docs/pages/index.htm
Apex Developer's Guide
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
Documentation overview:
http://wiki.developerforce.com/index.php/Documentation
Thanks for your reply. I saw your manual and I found a solution for another issues, but I cannot find the way to send data to a file already created and dislpayd in the contact visual force page, example the name of the fiel is "latitud_prueba__c" and the value is in javascript value "latlon", How I can send this javascript value to that field?
Below the complete code
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps API Sample</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></script>
<script type="text/javascript">
var map;
var geocoder;
var address;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(10.4910160,-66.9020610), 15);
map.addControl(new GLargeMapControl);
GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();
}
function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
document.getElementById("lat").value= place.Point.coordinates[1];// I can send this value to html field created
/******************************
I want to send this value "place.Point.coordinates[1]" to field "latitud_prueba__c" created in salesforce in the module Contact like additional fields.
************************************/
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
'<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
'<b>Address:</b>' + place.address + '<br>' +
'<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
<input name="lat" id="lat" type="text" readOnly="true" />
<div id="map_canvas" style="width: 700px; height: 400px"></div>
</body>
If I use the <apex:page standardController="contact"> at the beginning and </apex:page> at the end, I wont see the map in the module Contact of salesfroce.
Best Regards
can you post the visualforce code instead of the html output?
Hi, it is a s-control, I have not visual force code, is posible to show a value in a filed in a contact module? Please advise, that is all the code for this web page, that code display a google map.
Best Regards