Ciao a tutti,
sto cercando di realizzare un form con due menų a discesa collegati tra loro, grazie al vostro aiuto ci sono quasi riuscito, ma ho ancora un problema... quando scelgo la categoria il sotto menų funziona bene (nel senso che fa vedere solo le voci collegaate alla categoria selezionata), ma il menų categoria si resetta alla prima voce!
Questo č il codice:
codice:
<%@LANGUAGE="VBSCRIPT"%>
<%
Dim rsCategoria
Dim SQL
Dim SQL1
Dim rsCategoria_numRows
Set rsCategoria = Server.CreateObject("ADODB.recordset")
SQL = "SELECT * FROM CATEGORIE order by IDCATEGORIA DESC"
rsCategoria.Open SQL, conn
rsCategoria_numRows = 0
Dim rsModello
Dim rsModello_numRows
Dim modello
modello = "1"
If (Request.Form("sel_categoria") <> "") Then
modello = Request.Form("sel_categoria")
End If
Set rsModello = Server.CreateObject("ADODB.recordset")
SQL1 = "SELECT * FROM SOTTOCATEGORIE WHERE IDCATEGORIA=" & modello & " order by IDSOTTOCATEGORIA DESC"
rsModello.Open SQL1, conn
rsModello_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PROVA</title>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<select name="sel_categoria" id="sel_categoria" onChange="this.form.submit()">
<option value="Scegli la categoria" selected>Scegli la categoria</option>
<%
While (NOT rsCategoria.EOF)
%>
<option value="<%=(rsCategoria.Fields.Item("IDCATEGORIA").Value)%>"
<%
If (Not isNull((rsCategoria.Fields.Item("IDCATEGORIA").Value))) Then
If (CStr(rsModello.Fields.Item("IDCATEGORIA").Value) = CStr((rsModello.Fields.Item("IDCATEGORIA").Value))) Then
Response.Write("SELECTED") : Response.Write("")%> >
<% Response.Write(rsCategoria.Fields.Item("CATEGORIA").Value)
End if
End if
%>
</option>
<%
rsCategoria.MoveNext
Wend
%>
</select>
</p>
<select name="sel_sottocategoria" id="sel_sottocategoria">
<%
While (NOT rsModello.EOF)
%>
<option value="<%=(rsModello.Fields.Item("IDSOTTOCATEGORIA").Value)%>"><%=(rsModello.Fields.Item("SOTTOCATEGORIA").Value)%></option>
<%
rsModello.MoveNext()
Wend
%>
</select>
</p>
<input type="submit" name="Submit" value="Invia" />
</p>
</form>
</body>
</html>
<%
rsCategoria.Close()
Set rsCategoria = Nothing
%>
<%
rsModello.Close()
Set rsModello = Nothing
%>
Dove sbaglio? Forse l'evento onChange?
Ciao e grazie
Fabio