Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Ayuda con este codigo

Estas en el tema de Ayuda con este codigo en el foro de Frameworks JS en Foros del Web. Tengo este codigo que me han pasado y que no consigo hacerlo funcionar. Código PHP: < html > < style type = "text/css" > <!-- #posibles { ...
  #1 (permalink)  
Antiguo 16/12/2009, 19:21
 
Fecha de Ingreso: febrero-2008
Mensajes: 675
Antigüedad: 16 años, 3 meses
Puntos: 5
Ayuda con este codigo

Tengo este codigo que me han pasado y que no consigo hacerlo funcionar.

Código PHP:
<html>
<
style type="text/css">
<!--
#posibles {
    
width450px;
}
-->
</
style>

<
script language="javascript">
var 
xhr=false;
function 
startAjax(){
    if(
window.XMLHttpRequest){
        
xhr=new XMLHttpRequest();
    }else{
        try{    
            
xhr=new ActiveXObject("Microsoft.XMLHTTP");
        }catch(
e){}
    }

    if(
xhr!==false){
    var 
name=document.getElementById("name").value;
    
    
//archivo.php es en donde te conectas y haces la consulta
    
xhr.open("GET","autorrellenar.php?name="+name);
    
xhr.onreadystatechange=function(){
                if(
xhr.readyState==4){
                    if(
xhr.status==200){
                        var 
r=xhr.responseText;
                            if(
r.length>0){
                                var 
div=document.getElementById("posibles");
                                
div.innerHTML+=r+"<br />";
                            }else{
                                
clearTimeout(timer);
                            }
                    }
                }
                }
    
xhr.send(null);
    }
var 
timer=setTimeout("startAjax()",100);
}
</script>
<body>
<input type="text" name="name" id="name" onClick="startAjax()" onBlur="clearTimeout(timer);" />
<div id="posibles"></div>
</body>
</html> 
Y aqui esta la pagina autorrellenar.php
Código PHP:
<?php require_once('../Connections/noscasa.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_noscasa$noscasa);
$query_Recordset1 "SELECT usuario FROM gente";
$Recordset1 mysql_query($query_Recordset1$noscasa) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_free_result($Recordset1);
?>

<?php echo $row_Recordset1['usuario']; ?>
Si cargo la pagina autorrellenar.php, me saca un dato, o sea que funciona.
Mi pregunta es.... hace falta hacer algo mas para que me muestre el filtro?. segunda pregunta... cuando me funcione, como puedo seleccionar el dato que le pido y enviar por POST el ID?

Un saludo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:31.