PDA

View Full Version : automatic click in function



vsantoro
Oct 8th, 2010, 06:11 PM
Hi, hope someone can help. doing some work with google maps api. I have a function called codeaddress, this is triggered by a search button.
is there a way to add js to make an automatic click on results after search ?
here is code of function..




function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
map.setZoom(10);
} else {
alert("City was not found: " + status);
}
});
}

johnmerlino
Oct 8th, 2010, 06:32 PM
The onkeypress event can perform automatic checks. Are you using a library?


function whateverFunction(){
}

function check(e){
var code = e.keyCode || e.which;
if(code == 13){
e.preventDefault();
return obj.whateverFunction();
}


}
<input type="text" onkeyup="check(event)">

vsantoro
Oct 8th, 2010, 06:33 PM
using kml layer with mysql db for lat/lon.

basically, i just want this function to execute then a click on results[0].geometry.location