Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I was you I would set the focus to the Search button.</p> <p>So, if I understand correctly you have to enter an address and click search in order to do your geocoding.</p> <p>So, what I would do to make it as user friendly as possible is during the onload of the body I would setfocus to the address textbox.</p> <p>Then I would setfocus to the search button after the onleave/onblur event fires when you tab out of the address box. Then you would just hit enter and it would geocode.</p> <p>All in all you would need to add these two. :</p> <p>body onload -> setfocus to address textbox</p> <p>address textbox onblur/onleave -> setfocus to search button</p> <p>A third recommendation would be to setfocus back to the address textbox after the search button fires to start the process all over without leaving the keyboard.</p> <p>Here is a link on setting focus on load. On leave is pretty easy to use also.</p> <p><a href="https://stackoverflow.com/questions/45827/how-do-you-automatically-set-the-focus-to-a-textbox-when-a-web-page-loads">How do you automatically set the focus to a textbox when a web page loads?</a></p> <p>Here is a link about onblur. </p> <p><a href="http://www.w3schools.com/jsref/event_onblur.asp" rel="nofollow noreferrer">http://www.w3schools.com/jsref/event_onblur.asp</a></p> <p>Update to help you more.</p> <p>Ok, here is a demo page on how to use onblur etc. in pure javascript normally I would use jquery but I will keep it simple. I tried pasting it in but that didn't work.</p> <p><img src="https://i.stack.imgur.com/7JBmr.png" alt="enter image description here"></p> <p>Ok, last and final attempt, your code should look something like this, but the javascript tags need to be changed to be correct. </p> <pre><code> &lt;javascript tags&gt; var geocoder; function initialize() { geocoder = new google.maps.Geocoder (); //Set focuse to address textbox document.getElementById("address").focus(); } 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); marker.setPosition(results [0].geometry.location); map.setZoom(14); } else { alert("Geocode was not successful for the following reason: " + status); } }); //Either way set focus to address textbox document.getElementById("address").focus(); } function setFocusOnSearch() { //Set focus to search button now that you have left address textbox document.getElementById("search").focus(); } &lt;javascript tags end&gt; &lt;body onload="initialize()"&gt; &lt;div id="geocoder"&gt; &lt;input id="address" type="textbox" value="" "onblur="setFocusOnSearch()"&gt; &lt;input id="search" type="button" value="Search" onclick="codeAddress()"&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload