
19/11/2009, 10:01
|
| | Fecha de Ingreso: noviembre-2007
Mensajes: 30
Antigüedad: 17 años, 4 meses Puntos: 0 | |
Respuesta: Textbox actaualizable con Combobox en PHP Es que ni siquiera me devuelve error, yo selecciono del combo el cliente y ahi queda, te dejo el código a ver que te parece.
<HTML>
<HEAD>
<STYLE>
.hideable { position: relative; visibility: visible; }
</STYLE>
<SCRIPT>
function mostrar_ocultar(hide) {
if (document.layers)
document.contenido.visibility = hide ? 'show' : 'hide';
else {
var g = document.all ? document.all.contenido :
document.getElementById('contenido');
g.style.visibility = hide ? 'visible' : 'hidden';
}
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE border=0 cellspacing=1 cellpadding=1>
<TR>
<TD height="134" VALIGN="top">
<FORM NAME="form0">
<font color="red" size="4">Delivery
<INPUT TYPE="checkbox" NAME="Accion" ONCLICK="mostrar_ocultar(this.checked);">
</FORM>
</TD>
<TD>
<SPAN ID="contenido" CLASS="hideable">
<FORM NAME="form1" method=POST action=traerDatos.php>
<p>
<?php
$result=mysql_db_query($dbname, "SELECT * FROM clientes", $dbcon);
echo"Seleccione cliente <SELECT size=0 cols=24 NAME=id_cliente onChange=\"cargarClientes(this.value);\">";
echo"<OPTION value='0'>Elija Cliente</option>";
while($row = mysql_fetch_array($result)){
$id_cliente=$row["id_cliente"];
$domicilio=$row["domicilio"];
$nombre=$row["nombre"];
$apellido=$row["apellido"];
$nro=$row["numero"];
$depto=$row["depto"];
$telefono=$row["telefono"];
echo"<OPTION value=$row[0]>$row[1] $row[2]</OPTION>";
echo"</select>";
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript">
function nuevoAjax() {
var xmlhttp=false;
var ids = ["Msxml2.XMLHTTP.7.0","Msxml2.XMLHTTP.6.0","Msxml2. XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP. 3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
return xmlhttp;
}
$(document).ready(function (){
$('#nombre').change(function (){
$.post('getClientes.php', {
// pasando parametros post
id_cliente: $(this).val()
}, function (response){
//prefiero hacer esto que poner el tipo en el 4 parametro de $.post
response = $.evalJSON(response);
$('#domicilio').val(response.domicilio);
$('#numero').val(response.numero);
$('#telefono').val(response.telefono);
})
});
});
</script>
</head>
<body onload="cargarClientes();">
</div>
<div>
Nombre:
<div id="nombre">$nombre
</div>
Apellido:
<div id="Apellido">
</div>
Direccion:
<div id="Direccion" value=$direccion></div>
Numero:
<div id="Numero"></div>
Depto:
<div id="Depto"></div>
Telefono:
<div id="Telefono"></div>
getClientes.php
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<?php
include ("peligro.php");
include ("conexion.php");
// aqui hacemos la coneccion mysq, etc
$rs = mysql_db_query($dbname, "SELECT * FROM clientes WHERE id_cliente=" . $_POST['id_cliente'])or die(mysql_error());
$row = mysql_fetch_assoc($rs);
echo json_encode($row);
?>
<body>
</body>
</html> |