Tema: combos
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/12/2005, 07:57
Avatar de WILLIAMGG
WILLIAMGG
 
Fecha de Ingreso: febrero-2005
Mensajes: 218
Antigüedad: 19 años, 1 mes
Puntos: 0
Llenar Combos

<html>
<head>
<title>Untitled Document</title>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script>
function CaptaId(){
document.formulario.action="Creacorreo.asp?CboPais =" + document.formulario.CboPais.value;
document.formulario.action="Creacorreo.asp?CboDpto =" + document.formulario.CboPais.value;
alert(document.formulario.CboPais.value);
document.formulario.submit();
}
</script>
</head>

<body bgcolor="#FFFFCC">
<%set coneccion=server.createobject("ADODB.connection")
coneccion.Open "driver={SQL Server}; server=(local); database=hotmail; uid=sa; ;pwd=;"
%>
<form name=formulario method=post action="otrapagina.asp">
<table>

<tr><td><strong>Pais:</strong></td>
<%set tabla=coneccion.Execute("select * from PAIS")%>
<td><select name="CboPais" onchange="javascript:CaptaId();">
<option value="----"></option>
<%idpais=cint(Request.QueryString("CboDpto"))%>
<%do while not tabla.eof %>
<option value="<%=tabla("IdP")%>" <%if idpais=cint(tabla("IdP")) then%>Selected <%End if%>>
<%=tabla("Nombre")%></option>
<%tabla.movenext
loop%>
</select></td>
</tr>
<tr><td><strong>Nombres:</strong></td><td><input type="text" name="txtNombre" size=25 maxlength=30 value="<%=Request.Form("txtNombre")%>"></td></tr>
<tr><td><strong>Apellidos:</strong></td><td><input type="text" name="txtApell" size=25 maxlength=40 value="<%=Request.Form("txtApell")%>"></td></tr>

<%if Request.QueryString("CboDpto")<>"" then %>
<%identP=cint(Request.QueryString("CboDpto"))%>
<%set tablaD=coneccion.Execute("select * from DEPARTAMENTO where IdP="&identP&" ")%>
<tr><td><strong>Estado:</strong></td>
<td><select name="CboDpto" >
<option value="----"></option>
<%do while not tablaD.eof%>
<option value="<%=tablaD("IdD")%>"><%=tablaD("Nombre")%>
<%tablaD.movenext
loop%>
</select></td>
</tr>
<%tablaD.close
set tablaD=nothing%>
<%else%>
<tr><td><strong>Departamento:</strong></td><td><select name=CboDpto ></td></tr>
<%end if%>

<tr><td></td><td><input type=submit value="Grabar Datos Ingresados" name=grabar></td></tr>
</table>
<%tabla.close
set tabla=nothing
coneccion.Close
set coneccion=nothing%>
</form>

</body>
</html>


//////
Tabla Pais:IdP(llave) tipo int , Nombre varchar(35)
Tabla Departamento : IdD, IdP ambos Numeric(son llaves ambas), Nombre Vchar(35)

Eso es ASP con JavaScript
Espero Te sirva