Hola amigos a ver si me ayudan con este tema .
tengo un formulario , el cual lleno con un input evento (keyup)
y me carga la consulta por e valor que le ingreso en el input
hasta hay todo bien ,
lo que necesito hacer es que cuando tipee el input ,si no esta el registro en la consulta ,me debe traer/mostrar los inputs igual del formulario para yo llenarlos ,
pero como el ajax trae todo los input cargados de la consulta si el registro no existe
no se me muestran los input y no puedo llenarlos , se entiende?
en el fondo es si no esta el registro al tiepar el input me deben de aparecer igual los demas input para yo llenarlos y hacer el insert
he buscado info pero no encontrado y me he topado con varios ejemplos donde tienen el mismo problema
en la PAGINA2 tengo comentado un codigo al final que es el mismo formulario pero sin el resultado de la consulta , pero no se cmo mostrarlo
para poder llenarlo yo ..
a ver si me ayudan por favor !!
dejo el codigo para ser mas claro:
Saludos...
PAGINA 1:
Código Javascript
:
Ver original<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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","pagina2.php?q="+str,true);
xmlhttp.send();
}
</script>
Código HTML:
Ver original
<form id="form01" class="formular" method="post" action="usuarios_creados.php" name="form01" > <b>Buscar / Crear nuevo Registro
</b> Rut :
<input value="" class="" type="text" name="numero" id="numero" maxlength=12 onKeyUp="showUser(this.value)" />
<input class="submit" type="submit" value="Guardar"/><hr/>
PAGINA 2:
Código PHP:
<?php include("php_conexion.php");
$ms=$_GET["q"];
$sql="SELECT * FROM USUARIO WHERE ID = '".$ms."'";
$objParse = oci_parse ($objConnect, $sql);
oci_execute ($objParse);
while($row = oci_fetch_array($objParse))
{
echo ' <table border="0">';
echo ' <tr>';
echo ' <td valign="top">';
echo ' Nombre :';
echo ' <input value="'.$row['NOMBRES'].'" class="" type="text" name="nombres" id="nombres" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' Apellidos :';
echo ' <input value="'.$row['APELLIDOS'].'" class="" type="text" name="apellidos" id="apellidos" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' telefono :';
echo ' <input value="'.$row['TELEFONO'].'" class="" type="text" name="fono" id="fono" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' telefono fijo :';
echo ' <input value="'.$row['TELEFONO_FIJO'].'" class="" type="text" name="fono_2" id="fono_2" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' mail:';
echo ' <input value="'.$row['MAIL'].'" class="" type="text" name="mail" id="mail" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
}
oci_close($objConnect);
PODRIA MOSTRAR ESTE MISMO FORMULARIO PERO VACIOS DEBERIA SER CON IF MUESTRE FOMULARIO CON DATOS , ELSE FORMULARIO VACIO Y LLNERARLO YO ,PERO COMO?
/*
echo ' <table border="0">';
echo ' <tr>';
echo ' <td valign="top">';
echo ' Nombre :';
echo ' <input value="" class="" type="text" name="nombres" id="nombres" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' Apellidos :';
echo ' <input value="" class="" type="text" name="apellidos" id="apellidos" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' telefono :';
echo ' <input value="" class="" type="text" name="fono" id="fono" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' telefono fijo :';
echo ' <input value="" class="" type="text" name="fono_2" id="fono_2" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
echo ' <br>';
echo ' mail:';
echo ' <input value="" class="" type="text" name="mail" id="mail" maxlength="50" onKeyUp="this.value=this.value.toUpperCase();"/>';
*/
?>