Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/02/2008, 14:42
infolan
 
Fecha de Ingreso: noviembre-2005
Mensajes: 405
Antigüedad: 18 años, 6 meses
Puntos: 0
Re: evento onchange cargar un dato

Os paso mis paginas :

per_clientes.asp

<%@ LANGUAGE="VBScript" %>
<!-- #include virtual ="periodicos/adovbs.inc" -->
<% Response.Buffer=true %>
<!-- #include File = "..\connection\conexion.asp" -->
<!-- #include File = "..\asp\funciones.asp" -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script language="JavaScript1.2" src="../js/funciones.js"></script>
<script>
avisado=false;
//function searchPoblacion()
//{
// alert("searchPoblacion")
//}
function funciontest()
{
<%
response.write("<script>alert('fsdfdsfds')</script>")
%>
}
</script>
</head>
<%
txtCodigo = ""
txtNombre = ""
txtApellidos = ""
txtNIF = ""
txtTelefono1 = ""
txtTelefono2 = ""
txtDireccionLinea1 = ""
txtDireccionLinea2 = ""
txtCodigoPostal = ""
txtPoblacion = ""
txtProvincia = ""
txtObservaciones = ""
codigoProvincia = ""

tipoOperacion = request.QueryString("tipo")
codigo = request.QueryString("codigo")
response.write("Tipo : " & tipoOperacion & " - Codigo : " & codigo)

set con=Server.CreateObject("ADODB.Connection")
set rst = CreateObject("ADODB.Recordset")
con.Open strConnection
storedProcedureProv = "call SP_PROVINCIAS_S ();"
rst.activeconnection = con
rst.open = storedProcedureProv
con.Execute (storedProcedureProv)


if (codigo <> 0 ) then
set oConn=Server.CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")
oConn.Open strConnection
storedProcedure = "call SP_CLIENTES_L (" & codigo & ");"
rs.activeconnection = oConn
rs.open = storedProcedure
oConn.Execute (storedProcedure)

While not rs.EOF
txtCodigo = rs("cli_codigo")
txtNombre = rs("cli_nombre")
txtApellidos = rs("cli_apellidos")
txtNIF = rs("cli_nif")
txtTelefono1 = rs("cli_telefono")
txtTelefono2 = rs("cli_telefono2")
txtDireccionLinea1 = rs("cli_direccion_linea_1")
txtDireccionLinea2 = rs("cli_direccion_linea_2")
txtCodigoPostal = rs("cli_codigo_postal")
txtPoblacion = rs("cli_poblacion")
txtProvincia = rs("cli_provincia")
txtObservaciones = rs("cli_observaciones")
codigoProvincia = rs("provincia")

RS.moveNext
wend

if (txtProvincia <> "Falta") then
codigoProv = codigoProvincia
' response.write("<script>asignarProvincia('" & codigoProvincia & "');</script>")
End if

rs.close
oConn.close
end if
%>
<body class="bodyMantenimientos" onload="javascript:asignarProvincia('<%= codigoProv %>');">
<!-- PARTE SUPERIOR DE LA PANTALLA -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><h2>Pantalla clientes</h2></td>
</tr>
<tr>
<td class="texto2">En esta pantalla podrá dar de alta nuevos clientes o consultar información.</td>
</tr>
</table>
<br>
<!-- FORMULARIO -->
<form>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="10%" class="literal">Código :</td>
<td width="60%"><input type="Text" size="10" maxlength="10" value="<%= txtCodigo %>" disabled></td>
<td>
<img src="../images/img_mantenimientos/nuevo.gif" width="28" height="28" alt="Nuevo Registro" border="0" id="">
<img src="../images/img_mantenimientos/guardar.gif" width="28" height="28" alt="Guardar Registro" border="0" onclick="javascript:saveRegister(<%= tipo %>);" style="cursor:hand;">
<img src="../images/img_mantenimientos/borrar.gif" width="28" height="28" alt="Eliminar Registro" border="0">
<img src="../images/img_mantenimientos/cerrar.gif" width="28" height="28" alt="Cerrar Ventana" border="0" onclick="javascript:cerrarVentana();">
</td>
</tr>
<tr>
<td width="20%" class="literal">Nombre Completo :</td>
<td width="60%" colspan="2"><input type="Text" size="50" maxlength="100" name="txtNombre" value="<%= txtNombre %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Apellidos :</td>
<td width="60%" colspan="2"><input type="Text" size="50" maxlength="100" name="txtApellidos" value="<%= txtApellidos %>"></td>
</tr>
<tr>
<td width="20%" class="literal">NIF :</td>
<td width="60%" colspan="2"><input type="Text" size="11" maxlength="11" name="txtNIF" value="<%= txtNIF %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Teléfono 1 :</td>
<td width="60%" colspan="2"><input type="Text" size="15" maxlength="15" name="txtTelefono1" value="<%= txtTelefono1 %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Teléfono 2 :</td>
<td width="60%" colspan="2"><input type="Text" size="15" maxlength="15" name="txtTelefono2" value="<%= txtTelefono2 %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Dirección Línea 1 :</td>
<td width="60%" colspan="2"><input type="Text" size="100" maxlength="100" name="txtDireccionLinea1" value="<%= txtDireccionLinea1 %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Dirección Línea 2 :</td>
<td width="60%" colspan="2"><input type="Text" size="100" maxlength="100" name="txtDireccionLinea2" value="<%= txtDireccionLinea2 %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Código Postal :</td>
<td width="60%" colspan="2">
<!--<input type="Text" size="6" maxlength="6" onchange="javascript:compruebaValidoCP(this.id);" id="txtCodigoPostal" name="txtCodigoPostal" value="">-->
<input type="Text" size="6" maxlength="6" onchange="javascript:muestra_pob(this.value);" id="txtCodigoPostal" name="txtCodigoPostal" value="<%= txtCodigoPostal %>">
<img src="../images/img_mantenimientos/filtrar.gif" width="28" height="28" alt="">
</td>
</tr>
<tr>
<td width="20%" class="literal">Población :</td>
<div id="muestra_pob"/>
<td width="60%" colspan="2"><input type="Text" size="80" maxlength="80" name="txtPoblacion" value="<%= txtPoblacion %>"></td>
</tr>
<tr>
<td width="20%" class="literal">Provincia :</td>
<td width="60%" colspan="2">
<select id="provincias">
<%
While not rst.EOF
%>
<option value="<%= rst("prov_codigo")%>"><%= rst("prov_nombre")%></option>
<%
rst.moveNext
wend
rst.close
con.close
%>
</select>
<input type="Text" size="80" maxlength="80" name="txtProvincia" value="<%= txtProvincia %>" disabled>
</td>
</tr>
<tr>
<td width="20%" class="literal">Observaciones :</td>
<td width="60%" colspan="2"><textarea rows="7" cols="80" name="txtObservaciones" value="<%= txtObservaciones %>"></textarea></td>
</tr>

</table>
</form>


</body>
</html>




funcionesAJAX.js

function muestra_pob(val)
{
if (val.length<5) // para que no haga nada, mientras no ingreses 5 digitos
{
document.getElementById("txtCodigoPostal").innerHT ML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="pagina.asp"
url=url+"?q="+val
xmlHttp.onreadystatechange=stateChange
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function stateChange()
{
if (xmlHttp.readyState!="complete")
{
document.getElementById("muestra_pob").innerHTML=" ...buscando datos, un momento por favor"
}
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("muestra_pob").innerHTML=x mlHttp.responseText
}
}




Y pagina.asp

<%@ LANGUAGE="VBScript" %>
<!-- #include virtual ="periodicos/adovbs.inc" -->
<% Response.Buffer=true %>
<!-- #include File = "..\connection\conexion.asp" -->
<!-- #include File = "..\asp\funciones.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>



</body>
</html>






Con toda esta información como sería mi caso?