Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    525

    impostare default su select multipla

    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;
    }

    }
    }

    }

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    525

    opsss tentativo

    Rieccomi...provando a ascorrere l'array dei valori selezionati,e impostando il defaulòt al corrispondente indice della select...perchè nn funzia????

    //assegnazione di un valori di default nella seconda select
    for ( v = 0; v < valore_default.length; v++ ) {
    if ( a[d][0] == intType ) {
    t=a[d][1];
    alert("t ? v? " + t + " " + v);
    if (v == t){
    fItems.selectedIndex = fItems.options.length - v;
    }
    }
    }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.