Hello,
I've recently signed up for Google Cloud Services. One of the feature that they have is an API that can suggest / autofill addresses, in the process verifying such addresses and making sure they are valid.
I know that machform has a feature to allow for javascript to be loaded from a link. I setup a webpage and inserted the code at that page. The code is as follows.
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=[Api-Key-Is-Here]&libraries=places"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var places = new google.maps.places.Autocomplete(document
.getElementById('element_3_1'));
google.maps.event.addListener(places, 'place_changed', function() {
var place = places.getPlace();
var address = place.formatted_address;
var value = address.split(",");
count=value.length;
country=value[count-1];
state=value[count-2];
city=value[count-3];
var z=state.split(" ");
document.getElementById("element_3_6").text = country;
var i =z.length;
document.getElementById("element_3_4").value = z[1];
if(i>2)
document.getElementById("element_3_5").value = z[2];
document.getElementById("element_3_3").value = city;
var latitude = place.geometry.location.lat();
var longitude = place.geometry.location.lng();
var mesg = address;
document.getElementById("element_3_1").value = mesg;
});
});
The goal is to target element 3_1 which is the primary address field, which as the user starts typing it would give suggestions for the address they're trying to enter. Once the user selects an address from the dropdown it will then autofill the remainder. Which is Address Line 1: element 3_1 City: element 3_3 Zip: element 3_5 State: element 3_4 Country: element 3_6
I apply it to the form and try to load it and it just doesnt do anything. The form loads normally but the script isnt being injected.
Any ideas would be greatly appreciated.
Thank you!