<html>
<h1>TEST DE PERSONALIDAD</h1>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function Suma(formulario){
totalA=0
totalB=0;
nombre="";
for(i=0;i<formulario.elements.length;i++){
if(formulario.elements[i].type=="radio" && nombre!=formulario.elements[i].name ){
nombre=formulario.elements[i].name;
grupo=document.getElementsByName(nombre);
for(j=0;j<grupo.length;j++){
if(grupo[j].checked){
((totalA+=parseInt(grupo[j].value)))&&
(totalB+=parseInt(grupo[j].value));
}
}
}else if (formulario.elements[i].type=="checkbox"){
if(formulario.elements[i].checked){
totalA+=parseInt(formulario.elements[i].value);
}
}
}
document.form1.totalA.value = totalA;
document.form2.totalB.value = totalB;
}
</script>
</head>
<body>
<form method="post" name="form1">
<p>
<P>1
Animado <input name="grupo_radio" id="radio_2" onclick="Suma(this.form)" type="radio" value= "1" />
Aventurero <input name="grupo_radio" id="radio_1" onclick="Suma(this.form)"type="radio" value="1"/>
Analítico <input name="grupo_radio" id="radio_3" onclick="Suma(this.form)"type="radio" value="1"/>
Adaptable <input name="grupo_radio" id="radio_4" onclick="Suma(this.form)"type="radio" value="1"/>
<p>
<P>2
Juguetón <input name="grupo_radio2" id="radio_2" onclick="Suma(this.form)" type="radio" value="1"/>
Persuasivo <input name="grupo_radio2" id="radio_1" onclick="Suma(this.form)"type="radio" value="1" "/>
Persistente <input name="grupo_radio2" id="radio_3" onclick="Suma(this.form)"type="radio" value="1"/>
Cómodo <input name="grupo_radio2" id="radio_4" onclick="Suma(this.form)"type="radio" value="1"/>
</p>
<p>
total A<input name="totalA" type="text" value="0" />
</form>
<form method="post" name="form2">
<p>
total B<input name="totalB" type="text" value="0" />
</p>
</body>
</html>
I'm new to this and I'm doing this little code, I want to let me just select one of the 4 options per row and in the end I count how many A, B, C or D I have in total, I need help. Here I leave the code
PERSONALITY TEST
function Sum (form) { totalA = 0 totalB = 0; name=""; for (i = 0; i
1 Animated Adventurous Analytical Adaptable
2 Playful Persuasive Persistent Comfortable
total A
total B