7
I have two inputs, I’m using the automplete in only one. The code of the autocomplete:
$(document).ready(function() {
$.getJSON('include/funcoes/carrega_cidades.php', function(data){
var dados = [];
$(data).each(function(key, value) {
dados.push(value.name);
});
$('#cidade').autocomplete({ source: dados, minLength: 3});
});
});
cidade is the input who has the autocomplete and is returning normally.
I need to bring it to another input the id_cidade, City ID returned in autocomplete.
SQL:
$pdo = new PDO("mysql:host=localhost; dbname=iboard; charset=utf8;", "root", "");
$dados = $pdo->prepare("
SELECT
id,name
FROM
cidade
");
$dados->execute();
echo json_encode($dados->fetchAll(PDO::FETCH_ASSOC));
How can I do that?
+1Name in the array ? HSUAHSAUS– Gabriel Rodrigues