Ho scaricato questo script da http://www.jsdir.com/staffscripts/script048.asp
l'ho provato su Firefox e tutto oki, ma windows mi dà errori sul js che però non so come visualizzare. Lo script è compatibile con WS, infatti la demo sul sito funzia....Perchè questo invece non gira????
E' una select dinamica che si riempie di valori in base alla voce selezionata nella prima.I valori vengono presi da un array che contiene record di un db
Thxxxx
<script>
var arItems = new Array()
arItems = [
<?
$cmd = "SELECT * FROM aziende";
$rs = mysql_query($cmd);
while($aItems = mysql_fetch_array($rs)){
echo "['".$aItems['id_categoria']."','" .$aItems['id']."','".$aItems['label']."'],";
}
?>
]
function fillItems( intStart ) {
var fTypes = document.form1.db_sw
var fItems = document.form1.db_version
alert("intStart" + intStart )
var a = arItems
var b, c, d, intItem, intType
if ( intStart > 0 ) {
for ( b = 0; b < a.length; b++ ) {
if ( a[b][1] == intStart ) {
intType = a[b][0];
}
}
for ( c = 0; c < fTypes.length; c++ ) {
if ( fTypes.options[ c ].value == intType ) {
fTypes.selectedIndex = c;
}
}
}
if ( intType == null ) {
intType = fTypes.options[ fTypes.selectedIndex ].value
}
fItems.options.length = 0;
for ( d = 0; d < a.length; d++ ) {
if ( a[d][0] == intType ) {
fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] ); // no line-break here
}
if ( a[d][1] == intStart ) {
fItems.selectedIndex = fItems.options.length - 1;
}
}
}
</script>
<form name="form1">
<SELECT name="db_sw" id="db_sw" onChange="fillItems(form1.db_sw.options[form1.db_sw.selectedIndex].value)">
<option value="">select a sw type...</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</SELECT>
<SELECT name="db_version" id="db_version">
</SELECT>
</form>