Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/12/2011, 08:23
auri501
 
Fecha de Ingreso: octubre-2007
Mensajes: 130
Antigüedad: 16 años, 6 meses
Puntos: 2
check all checkbox error w3c

Tengo unas listas generadas mediante php y mysql dinamicamente, están divididas

por familias, y he usado un javascript que me marca todos los checkbox de esa

familia en concreto:
Código:
function selectCheckboxes(cat) { 
    var inputs = document.getElementsByTagName("input");
    var state;
    var tam = inputs.length;
	var i=0;
    while(inputs.length>i) {
        var obj = inputs[i];
         if ((obj.id == cat) && (obj.name!= cat)) {  
            state = obj.checked; // true or false 
            obj.checked = (state==true) ? false : true; 
        }
		
    i++;
	}
}

Este es el html que genero dinamicamente con php y mysql:

Código HTML:
<li>
            <h3 headerindex="1h" class="mypets openpet">laboral</h3>
            <div style="display: block;" contentindex="1c" class="thepet">
            <input name="66" onclick="selectCheckboxes(66);" type="checkbox"> 
            <span class="texto_menu_superior">Marcar todos [ laboral ]</span><br>
            <ul class="1_"> 
                            
              
            <li><br>
            <input name="242" id="66" value="Contratación" type="checkbox">
            <span class="texto_principal_peq"><strong>Contratación</strong>

            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It has survived not only five centuries, but also the leap into  electronic typesetting, remaining essentially unchanged. It was  popularised in the 1960s with the release of Letraset sheets containing  Lorem Ipsum passages, and more recently with desktop publishing software  like Aldus PageMaker including versions of Lorem Ipsum.<br></span>
            
        </li>
                          
              
            <li><br>
            <input name="243" id="66" value="Despidos" type="checkbox">
            <span class="texto_principal_peq"><strong>Despidos</strong>
            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It has survived not only five centuries, but also the leap into  electronic typesetting, remaining essentially unchanged. It was  popularised in the 1960s with the release of Letraset sheets containing  Lorem Ipsum passages, and more recently with desktop publishing software  like Aldus PageMaker including versions of Lorem Ipsum.<br></span>

            
        </li>
                          
              
            <li><br>
            <input name="244" id="66" value="Declaración renta" type="checkbox">
            <span class="texto_principal_peq"><strong>Declaración renta</strong>
            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It has survived not only five centuries, but also the leap into  electronic typesetting, remaining essentially unchanged. It was  popularised in the 1960s with the release of Letraset sheets containing  Lorem Ipsum passages, and more recently with desktop publishing software  like Aldus PageMaker including versions of Lorem Ipsum.<br></span>
            
        </li>
                          
              
            <li><br>

            <input name="245" id="66" value="prod3" type="checkbox">
            <span class="texto_principal_peq"><strong>prod3</strong>
            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It has survived not only five centuries, but also the leap into  electronic typesetting, remaining essentially unchanged. It was  popularised in the 1960s with the release of Letraset sheets containing  Lorem Ipsum passages, and more recently with desktop publishing software  like Aldus PageMaker including versions of Lorem Ipsum.<br></span>
            
        </li>
                          
              
            <li><br>
            <input name="246" id="66" value="prod4" type="checkbox">
            <span class="texto_principal_peq"><strong>prod4</strong>

            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;descr<br></span>
            
        </li>
                          
              
            <li><br>
            <input name="248" id="66" value="Contratos" type="checkbox">
            <span class="texto_principal_peq"><strong>Contratos</strong>
            <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Lorem ipsum dolor<br></span>

            
        </li>
                         </ul>
             </div>
             </li></ul> 
Funciona perfectamente, pero el w3c no lo valida, me aparecen los siguientes errores:
Cita:
Line 163, Column 51: value of attribute "id" invalid: "6" cannot start a name

… <input type="checkbox" name="244" id="66" value="Declaración renta" />



It is possible that you violated the naming convention for this attribute. For

example, id and name attributes must begin with a letter, not a digit.
Error Line 163, Column 51: ID "66" already defined

… <input type="checkbox" name="244" id="66" value="Declaración renta" />