RE:3 Combos dinámicos
Publicado por
Patricio (1 intervención) el 16/02/2009 02:48:25
Estimado este ejemplo funciona, Ojala te sirva.-
<script language="JavaScript" type="text/javascript">
<%'CONSULTA PARA OBTENER LOS DATOS DE SERVICIOS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("BDDDelivery.mdb"))
productos_Sql = "Select distinct Cod_Servicio, Cod_Cliente, Nom_Servicio from Servicios"
set rs = CreateObject("ADODB.Recordset")
rs.Open productos_Sql, Conn
x=0
%>
<%'CONSULTA PARA OBTENER LOS DATOS DE AFINIDAD
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("BDDDelivery.mdb"))
OTCliente_Sql = "SELECT DISTINCT Afinidad, cdbl(mid(OT_Delivery,9,3)) as xCliente, cdbl(mid(OT_Delivery,12,3)) as xServicio FROM DDelivery"
set rs2 = CreateObject("ADODB.Recordset")
rs2.Open OTCliente_Sql, Conn
x=0
%>
function sublist(inform, selecteditem)
{
alert(selecteditem);
inform.subcatagory.length = 0
<%
count= 0
y=0
do while not rs.eof
%>
x = <%= trim(y) %>;
subcat = new Array();
subcatagorys = "<%=(rs("Cod_Servicio"))&" "&(rs("Nom_Servicio")) %>";
subcatagoryof = "<%=(rs("Cod_Cliente"))%>";
subcatagoryid = "<%=(rs("Cod_Servicio"))%>";
subcat[x,0] = subcatagorys;
subcat[x,1] = subcatagoryof;
subcat[x,2] = subcatagoryid;
if (subcat[x,1] == selecteditem) {
var option<%= trim(count) %> = new Option(subcat[x,0], subcat[x,2]);
inform.subcatagory.options[inform.subcatagory.length]=option<%= trim(count)%>;
}
<%
count = count + 1
y = y + 1
rs.movenext
loop
rs.close
%>
}
function sublist2(inform2, selecteditem2)
{
alert(selecteditem2);
inform2.afinidad.length = 0
<%
count2= 0
y2=0
do while not rs2.eof
%>
x2 = <%= trim(y2) %>;
subcat2 = new Array();
subcatagorys2 = "<%=(rs2("xServicio"))&" "&(rs2("Afinidad")) %>";
subcatagoryof2 = "<%=(rs2("xCliente"))%>";
subcatagoryid2 = "<%=(rs2("xServicio"))%>";
subcat2[x,0] = subcatagorys2;
subcat2[x,1] = subcatagoryof2;
subcat2[x,2] = subcatagoryid2;
if (subcat2[x2,1] == selecteditem2) {
var option<%= trim(count2) %> = new Option(subcat2[x,0], subcat2[x,2]);
inform2.afinidad.options[inform2.afinidad.length]=option<%= trim(count2)%>;
}
<%
count2 = count2 + 1
y2 = y2 + 1
rs2.movenext
loop
rs2.close
%>
}
</script>
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #E8E8E8;
}
body,td,th {
color: #166D6A;
}
-->
</style></head>
<body>
<form name="prueba" method="post" action="">
<p align="center"><strong><u>VALIDACION DE FISICOS MECANIZADO CONTRA BASE RECEPCIONADA</u></strong></p>
<p align="center"> </p>
<tr>
<td>
<table width="50%" border="1" align="center">
<tr>
<td><font size=1 color=#000000 face="Arial">SELECCIONAR ITEM1:</font></td>
<td><select size="1" id="select7" name="familia" onChange = "javascript:sublist(this.form, familia.value);">
<option selected>Seleccionar Cliente</option>
<%familias_Sql = "Select distinct Cod_Cliente, Nom_Cliente from Clientes"
rs.Open familias_Sql, Conn
do while not rs.eof
%>
<option value="<%=rs("Cod_Cliente")%>"><%=rs("Nom_Cliente")%></option>
<%rs.movenext
loop
set rs=nothing
set rs2=nothing
conn.close
set conn=nothing%>
</select></td>
</tr>
<tr>
<td><font size=1 color=#000000 face="Arial">SELECCIONAR ITEM2:</font></td>
<td><select id="select8" name="subcatagory" size="1" onclick = "javascript:sublist2(this.form, subcatagory.value);">
<option selected value="none"></option>
</select></td>
</tr>
<tr>
<td><font size=1 color=#000000 face="Arial">SELECCIONAR ITEM3:</font></td>
<td><select id="select9" name="afinidad" size="1">
<option selected value="none"></option>
</select></td>
</tr>
</table></td>
</tr>
</form>
</body>
</html>