Ver Mensaje Individual
  #19 (permalink)  
Antiguo 23/08/2009, 20:24
phpnovato
 
Fecha de Ingreso: agosto-2009
Mensajes: 17
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Rellenar campos automaticamente...

Nuevamente voy a mandar todo el codigo para que puedas analizarlo un poco mejor.

<html>
<head>
<title>Prueba</title>
<script language="javascript" type="text/javascript">
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){ alert(cad);
// var parametro = "proveedor="+cad; alert(parametro);
xmlhttp.open("POST",pagina,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
resp = xmlhttp.responseText;
registro = resp.split('::~::');
document.getElementById('txttipo').value=registro[1];
document.getElementById('txtplaca').value=registro[2];
}
}
xmlhttp.send('proveedor='+escape(cad));
}
</script>
</head>
<body>
<?php
include("../db/coneccion.php");

$sql= ("select nombre_proveedor,extra1,extra2 from proveedores");
$rs=mysql_query($sql,$conectar);
$prov = mysql_fetch_array($rs);
//echo $prov['nombre_proveedor']."::~::".$prov['extra1']."::~::".$prov['extra2'];
?>
<form id="form1" name="form1" method="post" action="">
<select id="cmbproveedor" onChange="peticAjax('prueba2.php',document.getElem entById(this.id).options[document.getElementById(this.id).selectedIndex].value);">
<option value=''>--- Selecc. Proveedor ---</option>
<?php
while($prov1 = mysql_fetch_array($rs)){
echo "<option value=".$prove['nombre_proveedor'].">".$prov1['nombre_proveedor']."</option>";
}
?>
</select>
Tipo de Cami&oacute;n:<input name="txttipo" type="text" id="txttipo">
Placas:<input name="txtplaca" type="text" id="txtplaca" size="10">
</form>
</body>
</html>

Como te puedes dar cuenta tengo algo de codigo comentado, es lo que le he quitado.

Hasta ahora no he encontrado otra forma de hacerlo o bien de modificarlo mas lo que me has dicho.

Gracias.