Sono sempre io...nei precedenti posts ho trovato da sola soluzione...ma qui sono bloccata...Mi trovo a dover impostare 1 o + valori di default nella select ora multipla creata dinamicamente... valore_default è il nome della select che dovrebbe contenere solo i valori selezionati, è un array...ma nn funzia...
Thxxxxx!
function fillItems_form_report( intStart,valore_default ) {
var fTypes = document.my_form.categoria
var fItems = document.my_form.elements["attivita_demo[]"]
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;
}
//assegnazione di un valore di default nella seconda select
if ( a[d][0] == intType ) {
t=a[d][1];
if (valore_default== t){
fItems.selectedIndex = fItems.options.length - 1;
}
}
}
}