Ver Mensaje Individual
  #8 (permalink)  
Antiguo 21/08/2008, 08:26
Avatar de agressor
agressor
 
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Respuesta: Enviar datos en consulta ajax

Bueno mira este sera tu archivo de busqueda..

var xmlHttp

function showResult(fecha1,fecha2)
{
if (fecha1.length==0 && fecha2.length==0)
{
document.getElementById("livesearch").
innerHTML="";
document.getElementById("livesearch").
style.border="0px";
return
}

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}

var url="consulta.php"
url=url+"?fecha="+fecha1+"&fecha2="+fecha2
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("livesearch").
innerHTML=xmlHttp.responseText;
document.getElementById("livesearch").
style.border="1px solid #A5ACB2";
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

Ok mira este codigo que te puse aqui es bastante sencillo te mostrara los datos en un div que puedes colocar debajo de textbox.. y cuando lo puedes colocar en submit o Onchange

Aqui te mando el archivo de consulta.php

<?php
//Configuracion de la conexion a base de datos
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "";

$con = mysql_connect($bd_host, $bd_usuario, $bd_password);

mysql_select_db($bd_base, $con);

//consulta todos los empleados

$sql=mysql_query("select termino buscado where talcosa like '%".$_GET['q']."%' and '%".$_GET['q']."%'" ,$con);

//muestra los datos consultados
while($row = mysql_fetch_array($sql)){
echo "<div onKeydown=\"document.getElementbById('livesearch') .style.display='Block'\" onClick=\"document.getElementById('txt1').value=th is.innerHTML;document.getElementById('livesearch') .style.display='NONE';\">".$row['termino buscado']."</div>" ; }
?>

Espero te sirva no lo he probado lo hice a la carrera ahi me avisas..

Salu2..!!
__________________
Somos lo que nosotros queremos ni mas ni menos..
No hay dia mas perdido que aquel en que no hemos reido..
La vida es tal y como debe ser...
Nadie vivira por ti...

Última edición por agressor; 21/08/2008 a las 08:28 Razón: error