Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/09/2015, 04:52
pvsge
 
Fecha de Ingreso: febrero-2015
Ubicación: Alemania
Mensajes: 26
Antigüedad: 10 años, 1 mes
Puntos: 1
Problema suma variables

Hola a todos nuevamente.

Tengo el siguiente codigo

Código HTML:
Ver original
  1. <!DOCTYPE html><html>
  2. <title> Base Mundo de tinieblas</title>
  3. <meta charset = "utf-8">
  4. <style type = "text/css">
  5.  
  6. <input type = "radio" id = "af1" onclick = "chequeof1()">
  7. <input type = "radio" id = "af2" onclick = "chequeof2()">
  8. <input type = "radio" id = "af3" onclick = "chequeof3()">
  9.  
  10. <li>F<input  type = "text" id = "aff"></li>
  11. <li>D<input  type = "text" id = "afd"></li>
  12. <li>R<input  type = "text" id = "afr"></li>

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.  
  3. var vaf1 = document.getElementById("af1")
  4. var vaf2 = document.getElementById("af2")
  5. var vaf3 = document.getElementById("af3")
  6.  
  7. var b1 = [vaf1,vaf2,vaf3]
  8.  
  9. var vaff = parseInt(document.getElementById("aff"));
  10. var vafd = parseInt(document.getElementById("afd"));
  11. var vafr = parseInt(document.getElementById("afr"));
  12.  
  13. var numera = [7,5,3]
  14.  
  15. function suma(){
  16.     for (var i = 0; i < [a1.length]; i++){
  17.         if (b1[i].checked == true){
  18.             n = numera[i]
  19.             if (vaff + vafd + vafr == n){
  20.                 alert( "bien")
  21.             }
  22.            
  23.         }
  24.     }
  25.        
  26. }
  27.  
  28. </script>
</body>
</html>


El problema esta en que no se porque no me realiza la suma de las variables if (vaff + vafd + vafr == n). Alguien podria echarme una mano?Muchas gracias