PHP | Autocomplete data on multiple fields

the result I would need is very simple, given an autocomplete input, a city selected by the user I would like the latitude and longitude of the city chosen by the user to be completed in two hidden fields.

Now my code accesses an external wordpress table where, it allows the user to be able to select only the name of the city

table: places

table fields:

name lat lon 


roma 41.8933203 12.4829321 


<script>     /*ACCEDI ALLA LATITUDINE E LONGITUDINE DA TABELLA ESTERENA*/      var places_geo = <?php          global $  wpdb;          $  accedi_tabella = $  wpdb->get_results( "SELECT * FROM place" );          $  nomi_places = [];         foreach( $  accedi_tabella as $  place ){             $  nomi_places[] = $  place->name;         }         echo json_encode( $  nomi_places );         ?>;     places_geo.length||(places_geo=[]);     $  ('#form-geo').mdbAutocomplete({         data: places_geo     });      $  ('#form-geo').mdbAutocomplete({         data: places_geo     });  </script> 

input autocomplete:

<input type="search" id="form-geo" name="art"> 

as you can see from the script the value that will come out is only the name.

Now what I want

As said in the question, I would like that when the user clicks on: Rome, the results are output the two results of latitude and longitude in two hidden input fields

carry a jsfiddle, explaining what I want:

In the example typing google, at the time of selection, the selected result is displayed in the other two inputs. Well I would like two inputs to be displayed in the other two inputs (which currently do not exist) that show the fields: lat and lon