codice:
<script language="javascript">
// Create arrays containing Regioni, Province, Comuni
// Note: These arrays could be created dynamically
arr0 = ["Torino", "Asti"]
arr00 = ["Torino","Maglione","Massello","Bosconero","Bonzo"]
arr01 = ["Asti","Maretto","Tonico","Quaranti"]
arr1 = ["Milano", "Brescia", "Como", "Pavia"]
arr10 = ["Milano","Rozzano","Sesto San Giovanni","Arcore"]
arr11 = ["Brescia","Cerveno","Ossimo","Raffa"]
arr12 = ["Como","Lomazzo","Maggio"]
arr13 = ["Pavia","Stradella","Gerenzago","Landriano"]
arr2 = ["Roma", "Frosinone", "Viterbo"]
arr20 = ["Roma","Nettuno","Bracciano","Ariccia"]
arr21 = ["Frosinone","Strangolagalli","Supino"]
arr22 = ["Viterbo","Orte","Tarquinia"]
var arrReg
arrReg = [arr0, arr1, arr2]
// Function to handle dynamically altering the contents of the Reg List box
function RegChange(newDisplay)
{ var RegSelect, ProSelect, ComSelect, NumEntries, i
RegSelect = document.nav.Reg
ProSelect = document.nav.Pro
ComSelect = document.nav.Com
// Azzero Province
for (i = ProSelect.length; i > 0; i--) { ProSelect.options[i-1] = null }
// Aggiungi Commento
ProSelect.options[0] = new Option("-- Seleziona la Provincia --",-1)
// If Reg is selected add its Province to the Province List box
if (newDisplay >= 0)
{ NumEntries = arrReg[newDisplay].length
for (i = 1; i <= NumEntries; i++) { ProSelect.options[i] = new Option((arrReg[newDisplay])[i-1],(i-1)) }
}
ProSelect.selectedIndex = 0
ProChange()
}
// Function to handle dynamically altering the contents of the Pro List box
function ProChange(newDisplay)
{ var RegSelect, ProSelect, ComSelect, NumEntries, i
RegSelect = document.nav.Reg
ProSelect = document.nav.Pro
ComSelect = document.nav.Com
// Delete all entries in the Com list box
for (i = ComSelect.length; i > 0; i--) { ComSelect.options[i-1] = null }
// Add comment option to Com List box
ComSelect.options[0] = new Option("-- Seleziona il Comune --",-1)
// If Pro is selected add its Numeri to the Numeri List box
if (newDisplay >= 0)
{ tempNumeri = eval("arr"+RegSelect[RegSelect.selectedIndex].value+newDisplay)
NumEntries = tempNumeri.length
for (i = 1; i <= NumEntries; i++) { ComSelect.options[i] = new Option(tempNumeri[i-1],i-1) }
}
ComSelect.selectedIndex = 0
}
function vai() {
RegSelect = document.nav.Reg
ProSelect = document.nav.Pro
ComSelect = document.nav.Com
p1 = RegSelect[RegSelect.selectedIndex].value
p2 = ProSelect[ProSelect.selectedIndex].value
p3 = ComSelect[ComSelect.selectedIndex].value
// alert(""+p1+","+p2+","+p3)
if (p1>=0&&p2>=0&&p3>=0) {
n1 = RegSelect[RegSelect.selectedIndex].text
n2 = ProSelect[ProSelect.selectedIndex].text
n3 = ComSelect[ComSelect.selectedIndex].text
newURL = "http://my.server.it/"+n1+"/"+n2+"/"+n3+".htm"
alert(newURL)
// window.open(newURL)
} else {
alert("Scelta incompleta")
}
}
</script>
<form name="nav" action="javascript:vai(this);">
<table>
<tr>
<td class="TEXT"><font face="Arial" size="2">Regione:</font></td>
<td class="TEXT">
<select name="Reg" onChange="RegChange(this[this.selectedIndex].value)">
<option value="-1">-- Seleziona la Regione --
<option value="0">Piemonte
<option value="1">Lombardia
<option value="2">Lazio
</select>
</td>
</tr>
<tr>
<td class="TEXT"><font face="Arial" size="2">Provincia:</font></td>
<td class="TEXT">
<select name="Pro" onChange="ProChange(this[this.selectedIndex].value)">
<option value="-1">-- Seleziona la Provinia --
</select>
</td>
</tr>
<tr>
<td class="TEXT"><font face="Arial" size="2">Comune:</font></td>
<td class="TEXT">
<select name="Com">
<option value="-1">-- Seleziona il Comune --
</select>
</td>
</tr>
<tr>
<td class="TEXT"><font face="Arial" size="2"></font></td>
<td class="TEXT">
<input type=submit>
</td>
</tr>
</table>
</form>
<script language="javascript">
// questa va eseguito dopo la definizione del form per azzerare i menu
RegChange(-1)
</script>
Pero' non credo che ti convenga spedire una pagina contenente tutti i 14578 comuni e localita' d'italia... forse e' meglio svilupparlo lato server