Ver Mensaje Individual
  #6 (permalink)  
Antiguo 23/03/2005, 05:12
Avatar de KarlanKas
KarlanKas
Moderador extraterrestre
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 22 años, 5 meses
Puntos: 61
Aquí:
Código PHP:
$html=<form action="testpers.php" method="post" name="frm_test" id="frm_test"
cambialo así:
Código PHP:
$html=<form action="testpers.php" method="post" name="frm_test" id="frm_test" onsubmit="return comprobar(this)"
y añade esto en el head:
Código PHP:
<script type="text/javascript" charset="ISO-8859-1" language="JavaScript">
function 
comprobar(esto){
    
grupos=0;
    
marcados=0;
    for(
a=0;a<esto.elements.length;a++){
        if(
esto[a].type=="radio"){
            if(
esto[a].name!=esto[a-1].name){
                
grupos+=1
                
}
            if(
esto[a].checked){
                    
marcados+=1
                
}
        }
    }
    if(
marcados!=grupos){
        
alert("Has contestado "+marcados+" preguntas de un total de "+grupos+"\n\nPor favor, conteste a todas las preguntas!");
        return 
false
    
}
}
</script> 
Espero que te sirva!
__________________
Cómo escribir

No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia.

Última edición por KarlanKas; 23/03/2005 a las 05:13