Ver Mensaje Individual
  #8 (permalink)  
Antiguo 22/05/2011, 05:09
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Condiciones if()

A ver si te entendí:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>
<
script type="text/javascript">
function 
ver(f){
    var 
els=f.getElementsByTagName('input');
    var 
checks=0;
    for(var 
i=0,ch;ch=els[i];i++){
        if(
ch.type=='checkbox' && ch.checked){
            
checks=1;
            
alert('al menos uno');
            break;
        }    
    }
    if(!
checks)alert('ninguno');
    return 
checks;
}
</script>

</head>

<body>
<form id="form1" name="form1" method="post" action="" onsubmit="return ver(this)">
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="submit" value="Enviar" />
</form>
</body>
</html> 
Cita:
Creo que lo que necesitas es un XOR. Lamentablemente esto no existe en JS, pero es fácilmente imitable
amigo _cronos2, tengo que contradecirte:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin título</title>
<
script type="text/javascript">
function 
out(t){
    
document.getElementById('log').innerHTML+=t+'<br />';    
}
function XOR(
ab){ return (|| b) && !(&& b); }
onload=function(){
    
out(XOR(truetrue)); // false
    
out(XOR(falsefalse)); // false
    
out(XOR(truefalse)); // true
    
out('---------------------');
    
out(true true);
    
out(false false);
    
out(true false);
}
</script>
</head>

<body>
<div id="log"></div>
</body>
</html>