Utilizzo questo codice per creare due list box dinamche:
<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>
Il db è così composto:
tabella1
id_voce1 - contatore
voce1 - testo
tabella2
id_voce2 - contatore
voce2 - testo
id_voce1 - numerico (relazione tra tabella2 e tabella1)
tabella3
id_voce3 - contatore
voce3 - testo
id_voce2 - - numerico (relazione tra tabella3 e tabella2)
(Il codice è preso da
http://www.oscarjsweb.com/topic.asp?topid=76)
Praticamente adesso vorrei aggiungere la terza list box ma non so come fare!!
Qualcuno può darmi una mano?...grazie mille!