I would like to know how I can do a completion, I managed to do an autocomplete but it only leaves me the name, since the other td are not there, for example, description to be able to add, this is the modal:
But it turns out that I need autocomplete in all fields of type text and number , for this I use jquery, here is the html code and the jquery code:
<tbody>
<?php
while ($row = $resultado->fetch_assoc()) {
?>
<tr id="<?php echo $row["ID_CLIENTE"] ?>">
<td><?php echo $row["ID_CLIENTE"] ?></td>
<td data-target="rut"><?php echo $row["RUT"] ?></td>
<td data-target="nombre"><?php echo $row["NOMBRE"] ?></td>
<td data-target="fecha"><?php echo $row["FECHA_REGISTRO"] ?></td>
<td data-target="hora"><?php echo $row["HORA_REGISTRO"] ?></td>
<td data-target="usuario"><?php echo $row["USUARIO"] ?></td>
<td><a class=" visual_register" href="#" product="<?php echo $row["ID_CLIENTE"] ?>"><i class='bx bx-low-vision'></i></a></td>
<?php if (isset($_SESSION["administrador"])) : ?>
<td>
<form class="formulario-eliminar" method="POST">
<input type="hidden" name="ID_CLIENTE" value="<?= $row["ID_CLIENTE"] ?>">
<button type="submit"><i class="bx bxs-trash"></i></button>
</form>
</td>
<?php endif; ?>
<td><a class="btn-edit" product="<?php echo $row["ID_CLIENTE"] ?>" data-role="update" href="#" data-id="<?php echo $row["ID_CLIENTE"] ?>"><i class='bx bxs-edit-alt'></i></a></td>
</td>
</tr>
<?php } ?>
</tbody>
And this is my jquery code:
//Editar
$(".btn-edit").click(function(e){
e.preventDefault();
var id = $(this).attr('product'); //Obtengo el registro escogido guardando el id verificador
$(".modaleditar").fadeIn(); // Muestro el modal
var nombre = $("#"+id).children("td[data-target=nombre]").text()
$("#nombre").val(nombre);
As you can see, it has a data-target to verify in jquery, it only gives me the name, but if I try to produce another td that shows me, for example, an echo $row["description"] and then I make the jquery call It would work but I don't want to call another td because it would destroy my frontend, Thank you very much in advance!
When you do an autocomplete, for each field you fetch several rows from the database, so you must do a while for each of the fields, obviously with different sql statements