sì, è un mix di asp e javascript
codice by mems
Le list box dinamiche dovrebbero essere le SELECT FORM e, nel nostro caso, la dinamicità sta nel fatto che la seconda SELECT apparirà solo dopo aver scelto qualcosa dalla prima e con una serie di dati relazionati, ovviamente, alla scelta fatta sualla prima select.
Questo è un esempio basato su due tabelle di un db così composte:
tabella1
id_voce1 - contatore
voce1 - testo
tabella2
id_voce2 - contatore
voce2 - testo
id_voce1 - numerico (relazione tra tabella2 e tabella1)
codice:
<html>
<head><title></title>
<script language="JavaScript" type="text/JavaScript">
<!--
function jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options.value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<form name="selezione" method="post" action="">
<%
pagina = request.servervariables("path_info")
id = request.querystring("id")
if len(id) > 0 and isnumeric(id) then
id = clng(id)
else
id = 0
end if
set conn = server.createobject("adodb.connection")
conn.open ' la vostra stringa di connessione...
sql = "select * from tabella1"
set rs = conn.execute(sql)
if not rs.eof then
%>
<select name="tabella1" onChange="jumpMenu('parent',this,0)">
<option value="<%=pagina%>?id="></option>
<% do until rs.eof %>
<option value="<%=pagina%>?id=<%=rs("id_voce1")%>"<% if rs("id_voce1") = id then %> selected<% end if %>><%=rs("voce1")%></option>
<%
rs.movenext
loop
end if
%>
</select>
<%
rs.close
set rs = nothing
if id > 0 then
sql = "select * from tabella2 where id_voce1 = " & id
set rs = conn.execute(sql)
if not rs.eof then
%>
<select name="tabella2">
<option value="<%=rs("id_voce2")%>"></option>
<% do until rs.eof %>
<option value="<%=rs("id_voce2")%>"><%=rs("voce2")%></option>
<%
rs.movenext
loop
end if
%>
</select>
<%
rs.close
set rs = nothing
end if
conn.close
set conn = nothing
%>
</form>
</body>
</html>