ciao, grazie per le risposte.. in giro ho trovato un tutorial che tratta l'argomento.. ma non sono riuscito a ottenere il risultato desiderato.. questo é il codice:
a questo punto basterebbe richiamare la funzione all'onchange..Codice PHP:<script language="JavaScript">
var arItems = new Array()
arItems = [
<?
$cmd = "SELECT db_sw_id, db_version_id, version FROM db_version";
$rs = mysql_query($cmd);
while($aItems = mysql_fetch_array($rs)){
echo "[".$aItems['db_sw_id']."," .$aItems['db_version_id'].",'".$aItems['version']."']";
}
?>
]
</script>
<script>
function fillItems( intStart ) {
var fTypes = document.form1.db_sw
var fItems = document.form1.db_version
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>
Codice PHP:<td>
<SELECT name="db_sw" id="db_sw" onChange="fillItems(0);">
<option value="">select a sw type...</option>
<?
$type_list = GetListing("db_sw", "db_sw_id, db_sw_name");
foreach($type_list as $k => $v ) {
echo "<option value=\"$k\">$v</option>\n";
}
?>
</SELECT>
</td>
<td>
<SELECT name="db_version" id="db_version">
</SELECT>
ma non riesco a farlo funzionare.. qualcuno capisce il perché?
casomai il tutorial é qui:
http://www.devarticles.com/c/a/JavaS...s-Client-Side/

Rispondi quotando