0

I currently have two inputs like this

<input id="searchTextField" type="text" name ="start" size="50"><br>
<input id="searchTextField" type="text" name ="start" size="50"><br>

and this javascript

function initialize() {

var input = document.getElementById('searchTextField');

new google.maps.places.Autocomplete(input,options);        

}

How do I make the second text box also use google places autocomplete? I have been unable to figure this out.

toffoo
  • 29
  • 1
  • 4
  • Give the second input a different id and use the same code. HTML: `

    ` and **JS**: `function initialize() { var input1 = document.getElementById('searchTextField1'); var input2 = document.getElementById('searchTextField2'); new google.maps.places.Autocomplete(input1,options); new google.maps.places.Autocomplete(input2,options); }`
    – Aravind Voggu Dec 02 '18 at 20:39
  • Thanks for the reply but this does not work, it makes neither field autocomplete. – toffoo Dec 02 '18 at 20:48
  • You have to add an event listener to both of them. Are you doing that? – Aravind Voggu Dec 04 '18 at 05:48
  • I found another related thread, and possibly a duplicate https://stackoverflow.com/questions/20416058/adding-multiple-instances-of-google-places-on-same-page – Aravind Voggu Dec 04 '18 at 05:56
  • Possible duplicate of [Adding Multiple Instances of Google Places on Same Page](https://stackoverflow.com/questions/20416058/adding-multiple-instances-of-google-places-on-same-page) – Aravind Voggu Dec 04 '18 at 05:56

0 Answers0