Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Checkbox, solo 2 scelte

    Ciao
    come si fa a far scegliere solo 2 checkbox?
    MITTICCOOOOOOOOO!

  2. #2
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Puoi fare cosi ( testato su IE )

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    var maxChecked = 4;
    
    function controlla(checkbox,radice, numMass) {
     if (numMass == null) {
      numMass = maxChecked;
     } // if (numMass == null)
     oColl     = document.getElementsByTagName('INPUT');
     len       = oColl.length;
     checkedIn = 0;
     for (i=0;i<len;i++) {
      curObj = oColl.item(i);
    	if (curObj.type == 'checkbox' && curObj.id.substr(0,radice.length) == radice) {
    	 if (curObj.checked == true) {
    	  checkedIn ++;
    	 } // if (curObj.checked == true)
    	} // if (curObj.type == 'checkbox' && curObj.id.substr(0,radice.length) == radice)
     } //  for (i=0;i<len;i++) 
     if (checkedIn > numMass) {
      checkbox.checked = false;
    	return false;
     }
     return true;
    } // 
    //-->
    </script>
    
    </head>
    <body>
    Selezionare 2
    
    <input type="checkbox" id="cb1" onclick="controlla(this,'cb',2)">
    
    <input type="checkbox" id="cb2" onclick="controlla(this,'cb',2)">
    
    <input type="checkbox" id="cb3" onclick="controlla(this,'cb',2)">
    
    <input type="checkbox" id="cb4" onclick="controlla(this,'cb',2)">
    
    <input type="checkbox" id="cb5" onclick="controlla(this,'cb',2)">
    
    <input type="checkbox" id="cb6" onclick="controlla(this,'cb',2)">
    
    
    
    Selezionare 3
    
    <input type="checkbox" id="cc1" onclick="controlla(this,'cc',3)">
    
    <input type="checkbox" id="cc2" onclick="controlla(this,'cc',3)">
    
    <input type="checkbox" id="cc3" onclick="controlla(this,'cc',3)">
    
    <input type="checkbox" id="cc4" onclick="controlla(this,'cc',3)">
    
    <input type="checkbox" id="cc5" onclick="controlla(this,'cc',3)">
    
    <input type="checkbox" id="cc6" onclick="controlla(this,'cc',3)">
    
    
    
    Selezionare 4 (default - modificare maxChecked)
    
    <input type="checkbox" id="cd1" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd2" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd3" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd4" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd5" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd6" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd7" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd8" onclick="controlla(this,'cd')">
    
    <input type="checkbox" id="cd9" onclick="controlla(this,'cd')">
    
    
    </body>
    </html>

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 © 2026 vBulletin Solutions, Inc. All rights reserved.