I have a javascript function that is executing fine. When I goto update the form (client side) I get a handle on the input boxes, and can read (alert) their values but I can't set them....well it doesn't seem to set them as the client form doesn't update with the new values.
Here is the line in question:
document.getElementById("Address_AddyLat").value = results[0].geometry.location.lat();
As mentioned above both the element and the result are valid (alert). I even tried hardcoding a value in there and it didn't work??
Here is the full script:
function codeAddress()
{
var geocoder = new google.maps.Geocoder();
var addy1
......
geocoder.geocode({ 'address': fullAddress }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
document.getElementById("Address_AddyLat").value = results[0].geometry.location.lat();
document.getElementById("Address_AddyLong").value = results[0].geometry.location.lng();
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
});
}
Here is the html rendered:
<input name="Address.AddyLat" class="t-input" id="Address_AddyLat" style="color: rgb(255,255,255);" type="text" data-val-required="Internal Error Address Latitude Required" data-val-number="The field Address Latitude must be a number." data-val="true" value="999.9999"/>
More Info
Adding type made no difference and just for giggles I also outputted it via alert:
OBJECT HTMLInputElement
One other thing I noticed was that the server does a reload. huh? I tried adjusting the value manually and it actually throws an error. The real problem is not related so I've opened a new so question here.
Javascript local and global variables losing scope in callback function