I'm trying to create a form to register services performed, so I came across the first problem, I'm trying to keep it as light as possible because a lot of data. I want to store the "employee", "client", "services" ... I chose to use an autocomplete input bringing the name of the DB clients, however when it passes the 10 names it stops.
clientlist.php
<?php
$query_clientes = 'SELECT * FROM clientes';
$result_clientes = mysqli_query($conectar, $query_clientes);
while ($linhas_clientes = mysqli_fetch_assoc($result_clientes)){
echo '"'.htmlentities($linhas_clientes['nome']).'",';
}?>
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>autocomplete demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<label for="autocomplete">Clientes: </label>
<input id="autocomplete">
<script>
var tags = [ <?php include_once("listaclientes.php"); ?>];
$( "#autocomplete" ).autocomplete({
source: function( request, response ) {
var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
response( $.grep( tags, function( item ){
return matcher.test( item );
}) );
}
});
</script>
</body>
</html>
The generated code looks like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>autocomplete demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<label for="autocomplete">Clientes: </label>
<input id="autocomplete">
<script>
var tags = [ "Junior Santos","Michel","Cordeiro","Elton Costa","Mateus Eduardo","Eduardo","Deivinho","Rogerio Ribeiro","Sergio Ribeiro","Manuel Luiz Santos","Claudio Gomes","Evandson dos anjos
","Edmilson Cabral
","Junival alexandre
","Brendo Luiz
","Jessica Sabino ","Jhonatas","Paulo Vitor","Rafael Casal","Jaison Felix","Rubens Arruda",];
$( "#autocomplete" ).autocomplete({
source: function( request, response ) {
var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
response( $.grep( tags, function( item ){
return matcher.test( item );
}) );
}
});
</script>
</body>
</html>