Ver Mensaje Individual
  #32 (permalink)  
Antiguo 04/09/2007, 15:07
Avatar de Carxl
Carxl
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: Bogotá
Mensajes: 2.993
Antigüedad: 17 años, 9 meses
Puntos: 70
Re: Se puede hacer con AJAX??

Mira asì como te mando esto, me està sirviendo:

pagina de los select (formulario.php):
Código PHP:
<?php
session_start
();
require(
"funciones_php/funciones.php");

$id=$_GET['$id'];

$link=conexiondb();
if(
$link!=1)
{
    
$consulta="select * from ccl_clientes";
    
$result=mysql_query($consulta);
    
$row=mysql_fetch_array($result);
    
$num=mysql_num_rows($result);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="funciones_js/prototype.js" type="text/javascript"></script>
<script language="javascript">
Event.observe( window, 'load', function() 
{
      $('cliente').onchange = function() 
      {
              var itemSelected = this.options[this.selectedIndex].value;
              var pars = "cliente=" + escape(itemSelected);
              alert( pars );
              new Ajax.Request( 'select.php',
              {        
                      method: 'get',
          parameters: pars,
          onSuccess: function(transport) 
                      {
                        alert("Ajax Request completed! response: " + transport.responseText);
                        fillDatos( transport.responseText );
                    }
              }
        );
      };
});

function fillDatos( response ) {
      var items = response.split( "||" );
      var direccion = items[0];
      var telefono = items[1];
      var email = items[2];

      $('direccion').value = direccion;
      $('telefono').value = telefono;
      $('mail').value = email;
}
</script>

<title>: : : : : :  CORPORACION COLOMBIANA DE LOGISTICA : : : : : : :</title>
</head>

    <body leftmargin="0" topmargin="0">
        <select name="cliente" id="cliente">
            <option value="0">Seleccione</option>
            <?php
            
do
            {
            
?>
                <option value="<?php echo $row[0]?>"><?php echo substr($row[1],0,15)?></option>
            <?php
            
}while($row=mysql_fetch_array($result));                
            
?>
        </select>
        <input id="telefono" name="telefono"/>
        <input id="direccion" name="direccion"/>
        <input id="mail" name="mail"/>
    </body>
</html>
Y la de la consulta(select.php):
Código PHP:
<?php
require("funciones_php/funciones.php");

$idc=$_GET['cliente'];

$link=conexiondb();
if(
$link!=1)
{
    
$consulta="select * from ccl_clientes where ccl_cliente_id='$idc'";
    
$re=mysql_query($consulta);
    
$ro=mysql_fetch_array($re);
    echo 
$ro[4]."||".$ro[6]."||".$ro[8];
}
?>
Asì me funciona man!!!

Saludos!!!
__________________
Hay 10 tipos de personas, los que entienden binario y los que no. (Anónimo)
www.programandoweb.com