<script language="javascript" type="text/javascript">
var province = [ ["084", "AGRIGENTO", "19"],
var comuni = [ ["28001", "ABANO TERME", "028"],
function DropDownList_regioni_onchange(v)
{
//chiave regione
var key = v.value;
//cancello tutti le province
$("DropDownList_province").options.length = 1;
//cancello tutti i comuni
$("DropDownList_comuni").options.length = 1;
//creo lista provincia
for(var i in province)
{
if(province[i][2] == key)
{
lista_push($("DropDownList_province"), province[i][1], province[i][0]);
}
}
}
function DropDownList_province_onchange(v)
{
//chiave provincia
var key = v.value;
//cancello tutti i comuni
$("DropDownList_comuni").options.length = 1;
//creo lista comuni
for(var i in comuni)
{
if(comuni[i][2] == key)
{
lista_push($("DropDownList_comuni"), comuni[i][1], comuni[i][0]);
}
}
}
function DropDownList_comuni_onchange(v)
{
}
//al posto di mettere document.getElementById("div1"), mettere $("div1")
//da prototype.js
function $()
{
var elements = new Array();
for (var i = 0; i < arguments.length; i++)
{
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
function lista_push(lista, testo, valore)
{
lista.options[lista.options.length] = new Option(testo, valore);
}
</script>
<form action="<?php echo $PHP_SELf ?>" method="post">
<select name="regioni" id="DropDownList_regioni" onchange="return DropDownList_regioni_onchange(this)" style="width:200px;">
<option value="">Seleziona una Regione</option>
<option value="13">ABRUZZO</option>
</select>
<select name="DropDowbList_province" id="DropDownList_province" style="width:200px;" onchange="return DropDownList_province_onchange(this)">
<option value="">Seleziona Provincia</option>
</select>
<select name="comuni" id="DropDownList_comuni" style="width:200px;" onchange="return DropDownList_comuni_onchange(this)">
<option value="">Seleziona Comune</option>
</select>
<input type=hidden name=dati value=1>
<input type="submit" name="submit" value="Continua" />
</form>