Gracias amigo .... Dejo el código por si alguien en algún momento lo necesita
Código HTML:
Ver original <?php
$nombre = "";
require_once('conexion/conexion.php');
if ($conexion->connect_error) {//verificamos si hubo un error al conectar, recuerden que pusimos el @ para evitarlo
die('Error de conexión: ' . $conexion->connect_error); //si hay un error termina la aplicación y mostramos el error
}
$rtc = $conexion->query("SELECT * FROM rtc WHERE empresa = 'Microfertisa' ORDER BY nombre ASC");
if ($rtc->num_rows > 0){
while ($row2 = $rtc->fetch_array(MYSQLI_ASSOC)){
$nombre .="
<option value='".$row2['nombre']."'>".$row2['nombre']."
</option>";
}
}
?>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
<select name="users" onchange="showUser(this.value)"> <div id="txtHint"><b>Info personne sera énuméré ici ...
</b></div>
Y el otro archivo getuser.php
Código PHP:
Ver original<?php
$q = $_GET['q'];
$bodega = "";
if (!$con) {
}
$sql="SELECT * FROM bodegas WHERE rtc = '".$q."'";
$bodega .=" <option value='".$row['desc_bodega']."'>".$row['desc_bodega']."</option>";
}
echo "<select name='direccion' style='width:310px;' required><option>" . $bodega . "</option></select>";
?>