<html>
<head>
<script language="javascript">
var pays = new Array;
pays[0] = new Array("p0", "pays0");
pays[1] = new Array("p1", "pays1");
pays[2] = new Array("p2", "pays2");
var ville=new Array;
ville["p0"] = new Array;
ville["p0"][0] = new Array("p0v0", "pays0-ville0");
ville["p0"][1] = new Array("p0v1", "pays0-ville1");
ville["p1"]=new Array;
ville["p1"][0] = new Array("p1v0", "pays1-ville0");
ville["p1"][1] = new Array("p1v1", "pays1-ville1");
ville["p2"] = new Array;
ville["p2"][0] = new Array("p2v0", "pays2-ville0");
ville["p2"][1] = new Array("p2v1", "pays2-ville1");
var rue = new Array;
rue["p0v0"] = new Array;
rue["p0v0"][0] = new Array("p0v0r0", "pays0-ville0-rue0");
rue["p0v0"][1] = new Array("p0v0r1", "pays0-ville0-rue1");
rue["p0v1"] = new Array;
rue["p0v1"][0] = new Array("p0v1r0", "pays0-ville1-rue0");
rue["p0v1"][1] = new Array("p0v1r1", "pays0-ville1-rue1");
rue["p0v1"][2] = new Array("p0v1r2", "pays0-ville1-rue2");
rue["p1v0"] = new Array;
rue["p1v0"][0] = new Array("p1v0r0", "pays1-ville0-rue0");
rue["p1v0"][1] = new Array("p1v0r1", "pays1-ville0-rue1");
rue["p1v1"] = new Array;
rue["p1v1"][0] = new Array("p1v1r0", "pays1-ville1-rue0");
rue["p1v1"][1] = new Array("p1v1r1", "pays1-ville1-rue1");
rue["p2v0"] = new Array;
rue["p2v0"][0] = new Array("p2v0r0", "pays2-ville0-rue0");
rue["p2v0"][1] = new Array("p2v0r1", "pays2-ville0-rue1");
rue["p2v1"] = new Array;
rue["p2v1"][0] = new Array("p2v1r0", "pays2-ville1-rue0");
rue["p2v1"][1] = new Array("p2v1r1", "pays2-ville1-rue1");
rue["p2v1"][2] = new Array("p2v1r2", "pays2-ville1-rue2");
function filltheselect(liste, choix)
{switch (liste)
{
case "listepays":
raz("listeville");
raz("listerue");
for (i=0; i<ville[choix].length; i++)
{
new_option = new Option(ville[choix][i][1],ville[choix][i][0]);
document.formu.elements["listeville"].
options[document.formu.elements["listeville"].length]=new_option;
}
for (i=0; i<rue[choix+"v0"].length; i++)
{
new_option = new Option(rue[choix+"v0"][i][1],rue[choix+"v0"][i][0]);
document.formu.elements["listerue"].options[document.formu.
elements["listerue"].length]=new_option;
}
break;
case "listeville":
raz("listerue");
for (i=0; i<rue[choix].length; i++)
{
new_option = new Option(rue[choix][i][1],rue[choix][i][0]);
document.formu.elements["listerue"].options[document.formu.
elements["listerue"].length]=new_option;
}
break;
}
}
function raz(liste)
{l=document.formu.elements[liste].length;
for (i=l; i>=0; i--)
document.formu.elements[liste].options[i]=null;
}
</script>
</head>
<body>
<form name="formu">
Choisir un pays
<select name="listepays" onChange='javascript:filltheselect(this.name, this.value)'>
<script language="javascript">
for (i=0; i<pays.length; i++)
document.write("<option value=\"" +pays[i][0]+ "\">" +pays[i][1]);
</script>
</select>
<br>
Choisir une ville
<select name="listeville" onChange='javascript:filltheselect(this.name, this.value)'>
<script language="javascript">
for (i=0; i<ville["p0"].length; i++)
document.write("<option value=\"" +ville["p0"][i][0]+ "\">" +ville["p0"][i][1]);
</script>
</select>
<br>
Choisir une rue
<select name="listerue">
<script language="javascript">
for (i=0; i<rue["p0v0"].length; i++)
document.write("<option value=\"" +rue["p0v0"][i][0]+ "\">" +rue["p0v0"][i][1]);
</script>
</select>
</form>
</body>
</html>