Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/01/2013, 11:36
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Funcion de suma de campos de texto que no anda en Explorer

En casos así debés mostrar el html y como estás llamando la función, si no se transforma en una adivinanza.

Esto te funciona en cualquier navegador, incluso IE8/IE7

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. function calcular(cual){
  10. var caja=document.forms["sumar"].elements;
  11. var cantidad = Number(caja['cantidad'+cual].value);
  12. var precio = Number(caja['precio'+cual].value);
  13. var total = cantidad*precio;
  14. if(isNaN(total)){alert('error');}else{alert(total);}
  15. }
  16. //]]>
  17.  
  18. </head>
  19. <form name="sumar" action="#">
  20. Cantidad A <input type="text" value="" name="cantidad1"/><br />
  21. Precio A <input type="text" value="" name="precio1"/><br />
  22. Cantidad B <input type="text" value="" name="cantidad2"/><br />
  23. Precio B <input type="text" value="" name="precio2"/><br />
  24. <input type="button" onclick="calcular('1');" value="A1xA2" /><br />
  25. <input type="button" onclick="calcular('2');" value="B1xB2" /><br />
  26. </from>
  27. </body>
  28. </html>

Pero como te dije, estoy adivinando
Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.