1

I am getting the following error:

Uncaught Error: Invalid value for property <address>:

Following is the code that does the geocoding:

function codeAddress(zipcode){
var address = zipcode;
alert("Address is: " +address);
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
        map: map, 
        position: results[0].geometry.location
    });
  } else {
    alert("Geocode was not successful for the following reason: " + status);
  }
});
}

The function takes a parameter 'zipcode' from the following code:

<input type="button" value="Geocode" onclick="codeAddress(<%=resultset.getString(3)%>)">

Please help me on this.

3
  • 1
    What is resultset.getString(3) ? Commented Jan 5, 2012 at 5:25
  • for more information see the answer given by me at stackoverflow.com/questions/8679118/… Commented Jan 5, 2012 at 5:27
  • @amit resultset.getString(3) means that i am getting the value of zipcode from a SQL Database. Commented Jan 5, 2012 at 5:30

1 Answer 1

1

Make sure that the rendered onclick="codeAddress(<%=resultset.getString(3)%>)" actually has a string being passed to codeAddress(). You may have to add single quotes inside of that: onclick="codeAddress('<%=resultset.getString(3)%>')"

Sign up to request clarification or add additional context in comments.

3 Comments

It is getting passed. That is what i am checking in the third line of function codeAddress.
I don't mean "is it getting passed" but "is it a string?". You might be getting this error because address is a number, not a javascript string.
thanks you very much. I added single quotes and it is working as i wanted. And yeah, thank you for giving me above suggestion. Learned new thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.