ho trovato però ragazzi il codice è pesantissimo, ho 90 righe solo per 2 select dinamici. se ne devo fare 10 diventa un codice mostruoso.
lo posto magari voi avete idea di come ottimizzare o dove prendere qualche cosa di più leggero
codice:
<script>
function ShowSource()
{tv=window.open
("A100209_src.html","displayWindow","toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,left=0,top=0,width=650,height=450");
}
// Create arrays containing state cities
// Note: These arrays could be created dynamically
var arrStates, arrFlorida, arrNewYork, arrTennessee
arrFlorida = ["Daytona Beach", "Miami", "Orlando", "Tampa"]
arrNewYork = ["Albany","New York", "Oakland", "Rochester"]
arrTennessee = ["Gatlinburg", "Knoxville", "Memphis", "Nashville"]
arrTen = ["Gatl", "Knox", "Memphis", "Nashville"]
arrCicciopasticcio = ["cccc", "aaa" , "dddfd"]
arrStates =[arrFlorida, arrNewYork, arrTennessee, arrTen, arrCicciopasticcio]
// Function to handle dynamically altering the contents of the City List box
function handleChange(newDisplay)
{ var StateSelect, CitySelect, NumEntries, i
StateSelect = document.nav.States
CitySelect = document.nav.Cities
// Delete all entries in the cities list box
for (i = CitySelect.length; i > 0; i--)
{ CitySelect.options[i-1] = null
}
// Add comment option to City List box
CitySelect.options[0] = new Option("-- Select City --",0)
// If state is selected add its cities to the City List box
if (newDisplay >= 0)
{ NumEntries = arrStates[newDisplay].length
for (i = 1; i <= NumEntries; i++)
{ CitySelect.options[i] = new Option((arrStates[newDisplay])[i-1],(i))
}
}
CitySelect.selectedIndex = 0
}
</script>
<script language="JavaScript">
function ViewCrossReference (selSelectObject)
{
if(selSelectObject.options[selSelectObject.selectedIndex].value != "")
{
location.href=selSelectObject.options[selSelectObject.selectedIndex].value
}
}
</script>
</head>
<body>
<form name="nav">
<table>
<tr>
<td class="TEXT"><font face="Arial" size="2">States:</font></td>
<td class="TEXT">
<select name="States" onChange="handleChange(this[this.selectedIndex].value)">
<option value="-1">-- Seleziona Stato --
<option value="0">Florida
<option value="1">New York
<option value="2">Tennessee
<option value="3">ten
<option value="4">Cicciopasticcio
</select>
</td>
</tr>
<tr>
<td class="TEXT"><font face="Arial" size="2">Città:</font></td>
<td class="TEXT"><select name="Cities">
<option value="-1">-- Select City --
<option>
<option>
<option>
<option>
<option>
</select>
</td>
</tr>
</table></form>
<script language="javascript">
handleChange(-1)
</script>