Ragazzi sto cercando di fare un menu a tendina interattivo ma non mi viene. Dove sbaglio? Non so dove sta l'errore perchè non mi fa nulla quando dovrebbe far comparire il risultato:
ajax.js:
poi il file pagina.php che è quello con il form:codice:function ajaxFunction() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } return xmlhttp; } xmlhttp = ajaxFunction(); function doFileRequest(filename, args, elem) { xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { elem.innerHTML=xmlhttp.responseText; } } var method = "GET"; if (args) method = "POST"; xmlhttp.open(method, filename, true); if (args) { xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", args.length); xmlhttp.setRequestHeader("Connection", "close"); } xmlhttp.send(args); }
Ed infine il file ajax.php.Codice PHP:<script type="text/javascript" src="ajax.js"></script>
<form>
Cerca un nome:
<select onchange="doFileRequest('ajax.php', '?val='+this.value, document.getElementById('content'))">
<option value="Pluto">Pluto</option>
<option value="Pipo">Pipo</option>
<option value="Gigio">Gigio</option>
</select>
</form>
<div id="content"></div>
Informazioni aggiuntive:Codice PHP:<?
echo $_POST['val'];
?>
1) Ho provato sia con $_GET che con POST.
2) Ho provato anche a mettere il name alla select ma non funzionava lo stesso.
Cosa/Dove sbaglio? Come lo sistemereste? Grazie

Rispondi quotando
