Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/06/2005, 07:40
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 22 años, 1 mes
Puntos: 5
hay muchas formas de hacerlo. esta es una de ellas.


Código:
 
<%
sSQL = "select * from catalogo_categorias order by titulo"
set RSCategorias = Master.Execute(sSQL)
%>
Código HTML:
<script language="javascript">
function cambiarcategoria(codcategoria) {
var f = document.form1
 
var subcategorias_tituo = new Array();
var subcategorias_codigo = new Array();
 
if (f.categorias.value != 0) {
<%
I = 0
if RSCategorias.bof=false and RSCategorias.eof=false then
	while not RSCategorias.eof
	 sSQL = "select * from catalogo_subcategorias where categoria=" & RSCategorias("codigo") & " and activado=true order by titulo"
	 set RSSubCategorias = Master.Execute(sSQL)
 
	 J = 0
	 response.Write("if (codcategoria == " & RSCategorias("codigo") & ") {") & vbcrlf
	 response.Write(vbtab & "f.subcategorias.options.length = 0;") & vbcrlf
	 response.Write(vbtab & "sub" & J & " = new Option(""Seleccione una Sub Categoría"",""0"",""defauldSelected"");") & vbcrlf
	 response.Write(vbtab & "f.subcategorias.options[" & J & "] = sub" & J & ";") & vbcrlf
	 J = J + 1
	 while not RSSubCategorias.eof
	 subc_codigo = RSSubCategorias("codigo")
	 subc_titulo = RSSubCategorias("titulo")
	 response.Write(vbtab & "sub" & J & " = new Option(""" & subc_titulo & """,""" & subc_codigo & ""","""");") & vbcrlf
	 response.Write(vbtab & "f.subcategorias.options[" & J & "] = sub" & J & ";") & vbcrlf
	 J = J + 1
	 RSSubCategorias.movenext
	 wend
 
	 response.Write("}") & vbcrlf
 
	 I = I + 1
	 RSCategorias.movenext
	wend
 
	RSCategorias.movefirst
end if
%>
} else {
f.subcategorias.options.length = 0;
sub0 = new Option("Seleccione una Sub Categoría","0","defauldSelected");
f.subcategorias.options[0] = sub0;
}
}
</script>
 
<form name="form1">
categorias
<select name="categorias" onChange="cambiarcategoria(this.value)">
<%
response.Write("<option value=""0"">Seleccione una Categoría</option>")
while not RSCategorias.eof
if RSCategorias("codigo") = categoria then
response.Write("<option value=""" & RSCategorias("codigo") & """ selected>" & RSCategorias("titulo") & "</option>")
else
response.Write("<option value=""" & RSCategorias("codigo") & """>" & RSCategorias("titulo") & "</option>")
end if
 
RSCategorias.movenext
wend
%>
</select>
 
subcategorias
<select name="subcategorias">
</select>
</form> 
saludos
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.