Consideralo solo un esempio didattico...
codice:
<html><head>
<script>
function completa(chi) {
getText('dati_utente.asp?idUtente='+chi);
if (xmlHttpTesto!="") {
opzioni = xmlHttpTesto.split("|")
document.tuaForm.indirizzo.value = opzioni[0];
document.tuaForm.cap.value = opzioni[1];
document.tuaForm.citta.value = opzioni[2];
document.tuaForm.pv.value = opzioni[3];
}
}
var xmlHttpTesto = "";
function createXMLHttp() {
var xmlhttp ;
try {
xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7
} catch (e) {
var MSXML_XMLHTTP_PROGIDS = new Array(
'MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP', // Internet Explorer 6
'Microsoft.XMLHTTP' // Internet Explorer 4,5
);
var success = false;
for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) {
try {
xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
success = true;
} catch (e) {}
}
if ( !success ) {
alert('Cant create XMLHttpRequest - not supported');
}
}
return xmlhttp;
}
function getText(qry) {
xmlHttpTesto="";
var xmlHttpObj = null;
xmlHttpObj=createXMLHttp();
xmlHttpObj.open('get', qry, true);
xmlHttpObj.onreadystatechange = function() {
alert(xmlHttpObj.readyState)
if (xmlHttpObj.readyState == 4) {
if (xmlHttpObj.status==200 || xmlHttpObj.status==304) {
xmlHttpTesto = xmlHttpObj.responseText;
} else { alert("connessione perduta - ricaricare la pagina"); return; }
}
}
xmlHttpObj.send(null);
delete xmlHttpObj;
}
</script>
</head><body>
<form name="tuaForm">
<select name="idUtente" onchange="completa(this.options[this.selectedIndex].value)">
<%
' qui apri la connessione al tuo db
Set rs = tuaConn.execute("select * from utenti")
Do Until rs.eof
response.write "<option value="""&rs("idUtente")&""">"&rs("numeUtente")&"</option>"
rs.movenext
Loop
rs.close
' qui chiudi la connessione al db
%>
</select>
<input type="text" name="indirizzo">
<input type="text" name="cap">
<input type="text" name="citta">
<input type="text" name="pv">
</form>
</body></html>
codice:
<%
' qui apri la connessione al tuo db
risposta = "|||" ' vuota se errore
Set rs = tuaConn.execute("select * from utenti where idUtente="&request("idUtente"))
If Not rs.eof
risposta = rs("indirizzo")&"|"&rs("cap")&"|"&rs("citta")&"|"&rs("pv")
End if
rs.close
' qui chiudi la connessione al db
response.write risposta
%>
Come puoi vedere, di ASP ce ne sta proprio pochino.... a riprova del fatto che per realizzare queste cose occorre avere competenze di altre tecnologie.
Non l'ho provato, avendolo fatto al volo con un po' di copia/incolla, mettici un pochino del tuo impegno per testarlo e adattarlo alle tue esigenze.
ciao