Tema: suma online
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 31/07/2013, 14:39
capredinson
 
Fecha de Ingreso: julio-2013
Mensajes: 16
Antigüedad: 10 años, 9 meses
Puntos: 0
Respuesta: suma online

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script>
function fncImc(){
caja=document.forms["notas"].elements;

var pri_not_pperiodo = Number(caja["p1"].value);
var seg_not_pperiodo = Number(caja["p2"].value);
var ter_not_pperiodo = Number(caja["p3"].value);
var cua_not_pperiodo = Number(caja["p4"].value);
primer_periodo=(pri_not_pperiodo + seg_not_pperiodo + ter_not_pperiodo + cua_not_pperiodo)/4;
if(!isNaN(primer_periodo)){
caja["p5"].value=Math.round(((pri_not_pperiodo + seg_not_pperiodo + ter_not_pperiodo + cua_not_pperiodo)/4)*10)/10;
}
}
</script>



<body>
<?php for ($i = 0; $i<=3; $i++) {?>
<form action="atencion1.php" method="post" name="notas" >
<input name="pri_not_pperiodo<?php echo $i;?>" id="p1" type="text" size="5" maxlength="8" onKeyDown="fncImc()" >
<input name="seg_not_pperiodo<?php echo $i;?>" id="p2" type="text" size="5" maxlength="8" onKeyDown="fncImc()">
<input name="ter_not_pperiodo<?php echo $i;?>" id="p3" type="text" size="5" maxlength="8" onKeyDown="fncImc()">
<input name="cua_not_pperiodo<?php echo $i;?>" id="p4" type="text" size="5" maxlength="8" onKeyDown="fncImc()">
<input name="primer_periodo" id="p5" type="text" size="5" maxlength="8">
</form>
<?php }?>

</body>
</html>

ese for que esta hay es por que en el verdadero codigo que tengo hay uno lo que pasa es que es muy extenso pero ese funciona pero loq eu quiero hacer es que el primier campo me funciona pero apartir del segundo no me hace nada como lo haga