Foros del Web » Programando para Internet » ASP Clásico »

Listas Dependientes

Estas en el tema de Listas Dependientes en el foro de ASP Clásico en Foros del Web. hola, compañeros del desarrollo, hace 1 semana atras subi un codigo q me estaba dando problemas con las listas pedendientes a BD, ahora les pkngo ...
  #1 (permalink)  
Antiguo 09/08/2006, 10:20
 
Fecha de Ingreso: junio-2006
Mensajes: 104
Antigüedad: 18 años
Puntos: 1
Exclamación Listas Dependientes

hola, compañeros del desarrollo, hace 1 semana atras subi un codigo q me estaba dando problemas con las listas pedendientes a BD, ahora les pkngo este codigo, q si funciona, pero no me trae los registros de segundo combo, En el primer combo me muestra todos los datos, pero en segundo salen vacios o no me los pone completos, me podrían ayudar.

Código:
<html> <head>
<link rel="STYLESHEET" type="text/css" href="css/letras.css">
<meta http-equiv="Content-Language" content="es">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>Ventas</title> </head>

<body onload="MOSTRAR()">
<%'Variables de conexion
Dim OCONN, RSProductos, RSTipo

SET OCONN= Server.CreateObject("ADODB.Connection")
OCONN.OPEN("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./Ventas.mdb"))

SET RSProductos=CreateObject("ADODB.Recordset") 
RSProductos.Source= "SELECT * FROM Productos ORDER BY Productos" 
RSProductos.Open ,OCONN, 2, 4

SET RSTipo=CreateObject("ADODB.Recordset") 
RSTipo.Source= "SELECT * FROM Precios ORDER BY Tipo_Producto" 
RSTipo.Open ,OCONN, 2, 4

DIM I, J, II, JJ%> 
<script language="vbscript"> 
DIM TIPOS(3000,1000) 
DIM TIPOS2(3000,1000) 
<% I=0 
II=0 
DO UNTIL RSProductos.EOF 
	J=1 
	JJ=1 
	DO UNTIL RSTipo.EOF 
		IF RSTipo("ID")=RSProductos("ID") THEN%> 
			TIPOS(<%=I%>,<%=J%>)="<%=RSTipo("Tipo_Producto")%>" 
			TIPOS2(<%=II%>,<%=JJ%>)="<%=RSTipo("ID")%>" 
			<%RSTipo.MOVENEXT 
			J=J+1
			JJ=JJ+1
		ELSE
			EXIT DO
		END IF
	LOOP 
	RSProductos.MOVENEXT 
	I=I+1 
	II=II+1 
LOOP%> 
</script> 

<h1 align="center">Venta de productos</h1>
<form name="FRMCLIENTE" method=POST target=_self action="">
<p align="center">Seleccione el producto a comprar:
<select size="2" NAME="Productos" onchange=MOSTRAR()> 
<%RSProductos.MOVEFIRST%> 
<%DO UNTIL RSProductos.EOF%> 
<option value="<%=RSProductos("Id")%>"><%=RSProductos("Productos")%></option> 
<%RSProductos.MOVENEXT%> 
<%LOOP%> 
</select>

<table border="1" width="80%" height="58" align="center">
  <tr>
    <td width="25%" height="1" align="center">
      <p align="center"><b>PRODUCTOS</b></p>
    </td><td width="13%" height="1" align="center">
      <p align="center"><b>Cantidad</b></p>
    </td>
    <td width="12%" height="1" align="center">
      <p align="center"><b>Comprar</b></p>
    </td><td width="21%" height="1" align="center">
      <p align="center"><b>Precio</b></p>
    </td>
    <td width="29%" height="1" align="center">
      <p align="center"><b>Sub-Total</b></p>
    </td>
  </tr>
  <tr>
    <td width="25%" height="1">
    <select size="1" NAME="Tipo"> 
<script language="vbscript"> 
SUB MOSTRAR() 
DIM TIPOProductos, VALOR, VALOR2, LONGITUD, J, OptionObj 
TIPOProductos= FRMCLIENTE.Productos.SelectedIndex 
FRMCLIENTE.Tipo.Length=0 
FOR J=1 TO UBOUND(TIPOS) 
VALOR=TIPOS(TIPOProductos,J) 
VALOR2=TIPOS2(TIPOProductos,J) 
IF VALOR<>"" THEN 
LONGITUD= FRMCLIENTE.Tipo.length 
SET OptionObj= Document.CreateElement("option") 
FRMCLIENTE.Tipo.add OptionObj 
SET Optionobj= NOTHING 
FRMCLIENTE.Tipo.item(LONGITUD).text=VALOR 
FRMCLIENTE.Tipo.item(LONGITUD).value=VALOR 
ELSE 
EXIT FOR 
END IF 
NEXT 
FRMCLIENTE.Tipo.selectedIndex=0 
END SUB 
</script></select> 
    </td>
    <td width="12%" height="1" align="center">
      <p align="center"><input type="checkbox" name="Copolvo" value="ON"></p>
    </td>
    <td width="21%" height="1">
    </td>
    <td width="29%" height="1">
      <p align="center"></td>
  </tr>
</table></Form></body>
<% RSProductos.CLOSE 
OCONN.CLOSE %>
El error con q me he topado es este:
El subíndice está fuera del intervalo 'TITOProductos'

Agradesco de antemano su ayuda, gracias.
  #2 (permalink)  
Antiguo 10/08/2006, 11:37
 
Fecha de Ingreso: junio-2006
Mensajes: 104
Antigüedad: 18 años
Puntos: 1
Otro Problema

Ya solucione el proble anterior de las listas, pero ahora no se como hacer que el precio que ya seleccione en mi combo final salga en un text, alguien me puede ayudar.

<html> <head>
<link rel="STYLESHEET" type="text/css" href="css/letras.css">
<meta http-equiv="Content-Language" content="es">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>Ventas</title> </head>

<body onload="MOSTRAR()">
<%'Variables de conexion
Dim OCONN, RSProductos, RSTipo

SET OCONN= Server.CreateObject("ADODB.Connection")
OCONN.OPEN("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./Ventas2.mdb"))

SET RSProductos=CreateObject("ADODB.Recordset")
RSProductos.Source= "SELECT * FROM Productos ORDER BY Productos"
RSProductos.Open ,OCONN, 2, 4

SET RSTipo=CreateObject("ADODB.Recordset")
RSTipo.Source= "SELECT * FROM Precios ORDER BY Tipo_Producto"
RSTipo.Open ,OCONN, 2, 4

DIM I, J, II, JJ%>
<script language="vbscript">
DIM TIPOS(3000,1000)
DIM TIPOS2(3000,1000)
<% I=0
II=0
DO UNTIL RSProductos.EOF
J=1
JJ=1
DO UNTIL RSTipo.EOF
IF RSTipo("ID")=RSProductos("ID") THEN %>
TIPOS(<%=I%>,<%=J%>)="<%=RSTipo("Tipo_Producto")%> "
TIPOS2(<%=II%>,<%=JJ%>)="<%=RSTipo("ID")%>"
<%RSTipo.MOVENEXT
J=J+1
JJ=JJ+1
ELSE
EXIT DO
END IF
LOOP
RSProductos.MOVENEXT
I=I+1
II=II+1
LOOP%>
</script>

<h1 align="center">Venta de productos</h1>
<form name="FRMCLIENTE" method=POST target=_self action="">
<p align="center">Seleccione el producto a comprar:
<select size="1" NAME="Productos" onchange=MOSTRAR()>
<%RSProductos.MOVEFIRST%>
<%DO UNTIL RSProductos.EOF%>
<option value="<%=RSProductos("Id")%>"><%=RSProductos("Pro ductos")%></option>
<%RSProductos.MOVENEXT%> <%LOOP%>
</select>

<table border="1" width="80%" height="58" align="center">
<tr>
<td width="25%" height="1" align="center">
<p align="center"><b>Productos</b></p>
</td><td width="13%" height="1" align="center">
<p align="center"><b>Cantidad</b></p>
</td>
<td width="12%" height="1" align="center">
<p align="center"><b>Comprar</b></p>
</td><td width="21%" height="1" align="center">
<p align="center"><b>Precio</b></p>
</td>
<td width="29%" height="1" align="center">
<p align="center"><b>Sub-Total</b></p>
</td>
</tr>
<tr>
<td width="25%" height="1">
<select size="1" NAME="Tipo">
<script language="vbscript">
SUB MOSTRAR()
DIM TIPOProductos, VALOR, VALOR2, LONGITUD, J, OptionObj
TIPOProductos= FRMCLIENTE.Productos.SelectedIndex
FRMCLIENTE.Tipo.Length=0
FOR J=1 TO UBOUND(TIPOS)
VALOR=TIPOS(TIPOProductos,J)
VALOR2=TIPOS2(TIPOProductos,J)
IF VALOR<>"" THEN
LONGITUD= FRMCLIENTE.Tipo.length
SET OptionObj= Document.CreateElement("option")
FRMCLIENTE.Tipo.add OptionObj
SET Optionobj= NOTHING
FRMCLIENTE.Tipo.item(LONGITUD).text=VALOR
FRMCLIENTE.Tipo.item(LONGITUD).value=VALOR
ELSE
EXIT FOR
END IF
NEXT

FRMCLIENTE.Tipo.selectedIndex=0
END SUB
</script></select>

</td>
<td width="12%" height="1" align="center">
<p align="center"><input type="checkbox" name="Copolvo" value="ON"></p>
</td>
<td width="21%" height="1">
</td>
<td width="29%" height="1">
<p align="center"><input type="text" name="precio" size="20"></td>
</tr></table>
</Form></body>
<% RSProductos.CLOSE
OCONN.CLOSE%>

El codigo de rojo es mi ultimo combo, entonces yo quiero mandar desde ahi el precio de se producto q se seleccione a un text, como lo hago?????
gracias por su ayuda.
  #3 (permalink)  
Antiguo 10/08/2006, 11:41
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 3 meses
Puntos: 535
¿Por qué lo hacés en vbscript en vez de javascript?
Si lo hacés en vbscript sólo va a funcionar en IE.

(no sé a qué foro enviarte porque no hay uno de vbscript ¬¬)
__________________
...___...
  #4 (permalink)  
Antiguo 10/08/2006, 11:49
 
Fecha de Ingreso: junio-2006
Mensajes: 104
Antigüedad: 18 años
Puntos: 1
Solo eso necesito saber, como mando eso a un text, alguna forma de ponerlo en un variable o algo asi?, alguna idea.

No use javascript por q ya me habia tardado muchgo y no me salia, asi q intente con vbscript y me salio a la 3 ves, por eso, i no me queda mucho tiempo para entregar este proyecto, por eso intento los mas rapido. Ya despues lo paso en javascript.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 00:47.