Ciao.
Senza scomodare Ajax puoi recuperare
i valori di una query e metterli in un array js
poi ad esempio puoi utilizzare questo codice
(come tutte le cose si può migliorare
)
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>MyInput</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript" type="text/JavaScript">
function createInputText()
{
var myinput = document.createElement("input");
myinput.setAttribute("id", "myinput");
myinput.setAttribute("type", "text");
document.getElementById("frm").appendChild(myinput);
init();
}
function createSelect(myarray)
{
if(test = document.getElementById("myselect"))
{
document.getElementById("frm").removeChild(test);
}
var myinput = document.getElementById("myinput");
var index = myinput.value;
if(index=='' || index==0 || index > 10)
{
init();
return;
}
var myselect = document.createElement("select");
myselect.setAttribute("id", "myselect");
document.getElementById("frm").appendChild(myselect);
for (i=0; i < myarray[index].length; i++)
{
document.getElementById("myselect").options[i] = new Option(myarray[index][i],i);
}
}
function init()
{
var myselect = document.createElement("select");
myselect.setAttribute("id", "myselect");
document.getElementById("frm").appendChild(myselect);
document.getElementById("myselect").options[0] = new Option("------","0");
}
window.onload = function()
{
// QUESTO LO PUOI FARE CON PHP
var myarray = new Array();
myarray[1] = new Array("uno1","due1","tre1");
myarray[2] = new Array("uno2","due2","tre2");
myarray[3] = new Array("uno3","due3","tre3");
//etc
myarray[10] = new Array("uno10","due10","tre10");
createInputText();
var myinput = document.getElementById("myinput");
myinput.onkeyup = function()
{
createSelect(myarray);
}
}
</script>
</head>
<body>
<form id="frm" action="mypage.php" method="post" name="frm">
</form>
</body>
</html>
Spero che ti possa aiutare.