Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/10/2010, 11:24
Avatar de Perr0
Perr0
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 19 años, 10 meses
Puntos: 79
Respuesta: Cálculo matemático

prueba esto, por último chequeando podras corregir tu error

Código HTML:
<!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=iso-8859-1" />
<title>C&aacute;lculo</title>
<script>
function calc(){
	var a=document.getElementById("num1")
	var b=document.getElementById("num2")
	var c=document.getElementById("num3")
	var d=document.getElementById("num4")
	var e=document.getElementById("num5")
	ereg=/\d$/ //sólo numeros
	
	if(!a.value.match(ereg)) {alert("sólo numeros en a\"A\"");a.focus();return false}
	if(!b.value.match(ereg)) {alert("sólo numeros en a\"B\"");b.focus();return false}
	if(!c.value.match(ereg)) {alert("sólo numeros en a\"C\"");c.focus();return false}
	if(!d.value.match(ereg)) {alert("sólo numeros en a\"D\"");d.focus();return false}
	if(!e.value.match(ereg)) {alert("sólo numeros en a\"E\"");e.focus();return false}
	
	formula1=a.value-b.value
	formula1=formula1/7
	formula2=c.value*1+d.value*1
	formula2=formula2/5
	var ress=(formula1-formula2)*e.value
	
	document.getElementById("res").innerHTML=ress
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p>N&uacute;mero A: 
    <input type="text" name="num1" id="num1" maxlength="4" size="10" />
    <br />
    N&uacute;mero B:
  <input type="text" name="num2" id="num2" maxlength="4" size="10" />
  <br />
    N&uacute;mero C:
  <input type="text" name="num3" id="num3" maxlength="4" size="10" />
  <br />
    N&uacute;mero D:
  <input type="text" name="num4" id="num4" maxlength="4" size="10" />
  <br />
    N&uacute;mero E:
  <input type="text" name="num5" id="num5" maxlength="4" size="10" />
  </p>
  <p>
    <input type="button" name="c" id="c" value="Calcular" onclick="calc()" />
  </p>
</form>

<div style="background-color:#FFFF80; margin-top:20px; width:300px; padding:10px">F&oacute;rmula: ((A-B)/7) - ((C+D)/5) * E<br />
  Resultado: <span id="res" style="font-weight:bold">?</span>
</div>
</body>
</html> 
salu2