Salve a tutti ho un problema, ho bisogno di creare per il mio form una serie di select per la riecrca di auto. La prima select deve contenere tutte le marche, la seconda tutti i modelli della marca scelta e la terza select deve contenere tutte le versioni del modello scelto.
I dati relativi a marche, modelli e versioni sono estratti da un DB. Dovrei usare ajax per l'estrazione delle marche, dei modelli e delle versioni.
Ecco il codice che ho creato per l'estrazione solo delle marche, e che non restituisce alcun risultato:
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var myRequest = null;
function CreateXmlHttpReq(handler) {
var xmlhttp = null;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlhttp.onreadystatechange = handler;
return xmlhttp;
}
function myHandler2() {
if (myRequest.readyState == 4 && myRequest.status == 200) {
e = document.getElementById("marche");
e.innerHTML = myRequest.responseText;
}
}
function marche() {
myRequest = CreateXmlHttpReq(myHandler2);
myRequest.open("GET","marche.php);
myRequest.send(null);
}
</script>
</head>
<body onLoad="marche()">
<div id="marche"></div>
</body>
</html>
mentre il file php per l'estrazione delle marche è il seguente:
<?php
include "connect.php";
$q = mysql_query("SELECT * FROM auto GRUOP BY marca");
?>
<select name="marche">
<?php while($r = mysql_fetch_array($q)){ ?>
<option value="<?php echo $r['marca']; ?>"><?php echo $r['marca']; ?></option>
<?php } ?>
</select>
Dove sbaglio??? forse nel creare la select direttamente dal file php?