Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/08/2006, 10:20
jbco
 
Fecha de Ingreso: junio-2006
Mensajes: 104
Antigüedad: 18 años, 10 meses
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.