Visualizzazione dei risultati da 1 a 4 su 4

Discussione: CheckBox dinamici

  1. #1
    Utente di HTML.it L'avatar di buji
    Registrato dal
    Nov 2002
    Messaggi
    178

    CheckBox dinamici

    Scusate se posto direttamente ma la ricerca è disabilitata.
    In pratica ho una checkbox fisso e una serie variabile di checkbox con lo stesso nome.
    Avrei bisogno che al clic su quello fisso si bloccassero tutti quelli con lo stesso nome e che al clic su uno qualsiasi di quelli con lo stesso nome si bloccasse quello fisso (procedimenti inversi).
    La domanda è: tutti quelli con lo stesso nome possono essere trattati come un checkbox unico oppure no?

    Grazie in anticipo
    Buji

  2. #2
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Ma se sono bloccati come si fa a bloccare quello fisso ?

  3. #3
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Prova cosi....
    Non è quello che hai chiesto ma la struttura da usare c'è

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function selectAll(aCheckbox) {
     nbFils = document.body.children.length;
     for(i=0;i<nbFils;i++) {
      curObj = document.body.children(i);
    	if (curObj.tagName == 'INPUT' && curObj.type == 'checkbox' && curObj.name == aCheckbox.name.substr(1,2)) {
        curObj.checked = aCheckbox.checked;
      } // 	if (curObj.tagName == 'INPUT' && curObj.type == 'checkbox' && curObj.name == aCheckbox.name.substr(1,2))
     } // for(i=0;i<nbFils;i++)
     return true;
    } // function compteCheck(aDiv)
    
    function blockParent(aCheckbox)  {
     document.getElementById('p'+ aCheckbox.name).checked = aCheckbox.checked;
    } // function blockParent(aCheckbox)
    //-->
    </script>
    
    </head>
    <body>
    <input type="checkbox" onclick="selectAll(this)" name="pg1" id="s01">Select all
    
    
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c01">un
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c02">deux
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c03">trois
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c04">quatre
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c05">cinq
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c06">six
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c07">sept
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c08">huit
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c09">neuf
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c10">dix
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c11">onze
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c12">douze
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c13">treize
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c14">quatorze
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c15">quinze
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c16">seize
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c17">dix-sept
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c18">dix-huit
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c19">dix-neuf
    
    <input type="checkbox" onclick="blockParent(this)" name="g1"  id="c20">vingt
    
    </body>
    </html>

  4. #4
    Utente di HTML.it L'avatar di buji
    Registrato dal
    Nov 2002
    Messaggi
    178
    Grazie mille, mi hai dato lo spunto giusto!
    Buji

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.