
25/06/2004, 12:12
|
| | Fecha de Ingreso: junio-2003 Ubicación: Santiago de Compostela
Mensajes: 603
Antigüedad: 21 años, 11 meses Puntos: 0 | |
A ver:
He intentado por enésima vez hacerlo por partes y ahora creo que está bien salvo que me funciona a veces.
Cuando se carga la página se listan en comboarticulo los articulos que estan dados de alta en la DB.
Se trata de conseguir que el usuario vea los distintos tipos de tallaje que ya existen dados de alta de un artículo.
Entonces cuando se hace click sobre el botón "Consultar tallajes" deben aparecer reflejados los tallajes correspondientes a ese artículo.
Las tablas que uso no están vacias y tienen la estructura siguiente:
tabla Nombre campo tipo de datos
-------- -------------- -------------
articulostalla id Autonumérico
articulo texto
tallas id numéro
talla texto
Paso el código para que lo veas (si es que se ve ;) )
Código
-----------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
response.Expires=0
Response.AddHeader "PRAGMA", "NO-CACHE"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin título</title>
</head>
<!--Incluimos el fichero de constantes-->
<!--#INCLUDE file="../ADOVBS.asp"-->
<%
comboarticulo=request.form("comboarticulo")
response.write("El valor del combo es: " & comboarticulo)
%>
<%'Conectamos a la base de datos
set Conn= Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DSN=clubviajesoferta.com.amancio"
Conn.open
Set RS=Server.CreateObject("ADODB.Recordset")
RS.activeconnection=Conn
RS.source="articulostalla"
RS.Locktype = adLockOptimistic
RS.CursorType = adOpenDinamic
RS.open
%>
<%
'Conectamos a la base de datos
Set Command= Server.CreateObject("ADODB.Command")
' Abrimos el Recordset RS2 para realizar la consulta del combotallasexistentes
Command.ActiveConnection=Conn
Command.CommandType=adCmdText
'Si se sustituye la línea siguiente por :
' Command.CommandText= "Select * From tallas"' WHERE id = " & comboarticulo
' verás que no hay ningun error en las tablas
Command.CommandText= "Select * From tallas WHERE id = " & comboarticulo & " ORDER BY talla"
Set RS2=Command.Execute ()
%>
<body>
<form action="anadir_talla.asp" method="post" name="form1" id="form1">
<table width="30%" border="0">
<tr valign="top">
<td width="68%">Tallas existentes </td>
<td width="16%"><select name="combotallasexistentes" size="5" id="combotallasexistentes">
<%
if not (rs2.bof and rs2.eof) then
rs2.movefirst
do while not rs2.eof
%>
<option value="<%=rs2("talla")%>"><%=rs2("talla")%></option>
<%
rs2.movenext
loop
end if
%>
</select></td>
<td width="16%"><input type="submit" value="Consultar tallajes"></td>
</tr>
</table>
<p> </p>
<p>Articulo
<select name="comboarticulo" id="comboarticulo">
<%
if not (rs.bof and rs.eof) then
rs.movefirst
do while not rs.eof
%>
<option value="<%=rs("id")%>" selected><%=rs("articulo")%></option>
<%
rs.movenext
loop
end if
%>
</select>
</p>
</form>
</body>
<%
rs.close
rs2.close
conn.close
%>
</html>
------------------------
Fin de código |