I added autocomplete places to a google map and have a FROM and TO input fields. The TO input has a fixed value, when the users choose an address from the suggestions and press the TAB or ENTER key it submit the route and works fine!
But when the user click on a suggestion, it doesn't show the route. How can I handle the place_changed as a enter OR tab key?
The code in HTML:
<div id="controls">
<label><span>Van:</span> <input class="test" id="vertrek" type="text" name="from"></label>
<label><span>Naar:</span> <input type="text" id="bestemming" name="to" readonly></label>
</div.
In JavaScript I tried this:
google.maps.event.addListener(autocomplete, 'place_changed', function() {
document.getElementById("vertrek").focus();
return false;
});
It doesn't work, I don't know why because when I add a window.alert and select an item from the suggestion list it shows the alert.
I also tried to put the input fields in a form tag and change the .focus to .submit, it doesn't work also.
Shortly: I want to make it possible to handle the click on the suggestion list as a keypress (tab OR enter)