Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/09/2008, 16:06
Juan_Bautista
 
Fecha de Ingreso: septiembre-2008
Mensajes: 19
Antigüedad: 15 años, 8 meses
Puntos: 5
Respuesta: ComBo que al modificar rellene varios textbox

Hola,
Una solución php-ajax:

index.php

Incluir en <head>:
<script type="text/javascript" src="func_ajax.js"></script>

Código PHP:
<?php
//Conexión
//Consulta
//..................................................................................................................
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
<select id=\"cmbClientes\" onchange=\"peticAjax('sqldb.php',this.value)\">
<option value=''>--- Selecc. Cliente ---</option>"
;    
while(
$cliente mysql_fetch_array($tbl_clientes)){
    echo 
"<option value=".$cliente['RFC'].">".$cliente['NOMBRE']."</option>";    
}
echo 
"</select>
RFC:<input name=\"txtRFC\" type=\"text\" id=\"txtRFC\" size=\"3\" />
DIRECCI&Oacute;N:<input name=\"txtDIRECC\" type=\"text\" id=\"txtDIRECC\" size=\"60\" />
</form>"
;
//..................................................................................................................
?>
func_ajax.js

Código PHP:
var xmlhttp false;
//---
try {
    
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (
e) {
    try {
        
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (
E) {
        
xmlhttp false;
    }
}
if (!
xmlhttp && typeof XMLHttpRequest != 'undefined') {
    
xmlhttp = new XMLHttpRequest();
}
//---
function peticAjax(pagina,cad){
    var 
parametro "RFC="+cad;
    
xmlhttp.open("POST",pagina,true);
    
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    
xmlhttp.onreadystatechange = function() {
        if (
xmlhttp.readyState == && xmlhttp.status == 200) {
            
resp xmlhttp.responseText;
            
registro resp.split('::~::');
            
document.getElementById('txtRFC').value=registro[0];
            
document.getElementById('txtDIRECC').value=registro[1];
        }
    }
    
xmlhttp.send(parametro);

sqldb.php

Código PHP:
<?php
$RFC
=$_POST['RFC'];
//---
mysql_connect("servidor","usuario","clave");
mysql_select_db("basedatos");
$sql="select RFC,DIRECCION from clientes where RFC=$RFC";
$rs=mysql_query($sql);
$cliente mysql_fetch_array($rs);
echo 
$cliente['RFC']."::~::".$cliente['DIRECCION'];
?>