I'm setting up a register where I select the state and an ajax searches the cities the client selects the city I show a form for him to type the name of the neighborhood where I use the auto complete my question is how to get the id of this form / neighborhood that he found a step to another form that should use the form id / neighborhood to perform new auto complete and after that send it to a script that will insert everything in the database.
What I already have is the following auto complete code I would like help with putting together this second part
search_boir.php
$pdo = new PDO("mysql:host=localhost; dbname=$db", "$user", "$senha",
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$dados = $pdo->prepare("SELECT * FROM bairro");
$dados->execute();
echo json_encode($dados->fetchAll(PDO::FETCH_ASSOC));
html
<input type="text" id="txtNome" name="txtNome" size="60"/>
<script src="jquery/jquery-ui-1.11.4/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Captura o retorno do retornaCliente.php
$.getJSON('busca_bairro.php', function(data){
var dados = [];
// Armazena na array capturando somente o nome do EC
$(data).each(function(key, value) {
dados.push(value.nome);
});
// Chamo o Auto complete do JQuery ui setando o id do input, array com os dados e o mínimo de caracteres para disparar o AutoComplete
$('#txtNome').autocomplete({ source: dados, minLength: 3});
});
});
</script>