The detail I have is that I have to validate a text (RFC) of an input, and that when clicking on a submit check, I return the clients with the same RFC in an option .... I already look and I do not understand how to do it ...
this part is the search with the SQL query
<label>
<select id="cbx_nombre" name="cbx_nombre">
<?php
include "conexion.php";
$consult = "SELECT *from usuarios3 where RFC = 'RFC123' "; /*AQUI VA EL RFC*/
$ejecutar=mysqli_query($conexion, $consult) or die (mysqli_error($conexion));
?>
<option>Selecciona::</option>
<?php
foreach ($ejecutar as $opciones):?>
<option value="<?php echo $opciones['id_cliente'] ?>">
<?php echo $opciones['id_cliente'] ?>
</option>
<?php endforeach ?>
</select>
</label>
I know that with jquery, but I do not understand 100 well how could I do that ...
<script type="text/javascript">
$(document).ready(function(){
var consulta;
//hacemos focus
$("#usuario").focus();
//comprobamos si se pulsa una tecla
$("#usuario").click(function(e){
//obtenemos el texto introducido en el campo
consulta = $("#usuario").val();
//hace la búsqueda
$("#resultado").delay(1000).queue(function(n) {
$("#resultado").html('<img src="ajax-loader.gif" />');
$.ajax({
type: "POST",
url: "comprobar.php",
data: "b="+consulta,
dataType: "html",
error: function(){
alert("error petición ajax");
},
success: function(data){
$("#resultado").html(data);
n();
}
});
});
});
});
</script>