Mi spiace un po' riportare del codice nuovamente ma, anche io ho lo stesso problema e anche dopo aver fatto le modifiche non riesco a visualizzare nulla nella seconda select (senza le modifiche consigliate la seconda select si popola con un testo lunghissimo del tipo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html lang="it-IT"><head> ecc.. ecc..").
Ora riporto il codice dei 3 file:
1) index.asp
2) _db.aspCodice PHP:
<!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>AJAX e ASP - Select concatenate</title>
<script language="javascript">
var ricerca_pro;
function cerca()
{
var valorecampo = document.form1.regione.options[document.form1.regione.selectedIndex].value;
// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
ricerca_pro = new XMLHttpRequest();
ricerca_pro.onreadystatechange = ricevi;
ricerca_pro.open("GET", "cercaprovince.asp?reg="+valorecampo,true);
ricerca_pro.send(null);
// per IE
} else if (window.ActiveXObject) {
ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
if (ricerca_pro) {
ricerca_pro.onreadystatechange = ricevi;
ricerca_pro.open("GET", "cercaprovince.asp?reg="+valorecampo,true);
ricerca_pro.send();
}
}
}
function ricevi() {
var strRes;
var arrValori;
if (ricerca_pro.readyState == 4) {
document.getElementById("document.form1.citta").innerHTML=ricerca_pro.responseText;
}
}
</script>
</head>
<%
'apro connessione e istanzio oggetti
OpenDB(connAJAX)
'query per la prima select
strsql = "SELECT id,regione FROM regioni"
rs.open strsql
%>
<body>
Scegli regione:
<form id="form1" name="form1" method="post" action="">
<label>regione
<select name="regione" accesskey="1" tabindex="1" onchange="cerca()">
<option selected="selected" value=0>Scegli regione</option>
<%
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=rs("regione")%></option>
<%
rs.movenext
loop
CloseDB
%>
</select>
</label>
<label>
città
<select name="citta" id="citta" accesskey="2" tabindex="2" >
</select>
</label>
</p>
</p>
</p>
</form>
</body>
</html>
3) cercaprovince.aspCodice PHP:
<%
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
connAJAX = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath("./db2.mdb")
'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
'---- CursorLocationEnum Values ----
Const adUseServer = 2
Const adUseClient = 3
'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004
Const adCmdFile = &H0100
Const adCmdTableDirect = &H0200
sub OpenDB(sConn)
conn.open sConn
set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
end sub
sub CloseDB()
rs.close
conn.close
set rs = nothing
set conn = nothing
end sub
sub w(sText)
response.write sText & vbCrLf
end sub
%>
Sicuramente il problema sarà dettato dal fatto che JS non lo mastico per nulla..Codice PHP:
<%
'apro connessione e istanzio oggetti
OpenDB(connAJAX)
reg = Request.QueryString("reg")
strsql = "SELECT citta FROM citta WHERE id_reg = " ®& ""
rs.open strsql
primo = 0
if not rs.eof then
do while not rs.eof
'compongo l'array con i risultati
if primo = 0 then
primo = 1
array_citta = rs("citta")
else
array_citta = rs("citta") & "|" & array_citta
end if
rs.movenext
loop
response.write array_citta
end if
CloseDB
%>
Spero di aver presto buone notizie!!![]()
Grazie![]()


Rispondi quotando