Foros del Web » Programando para Internet » Javascript »

Suma

Estas en el tema de Suma en el foro de Javascript en Foros del Web. buenas panas del foro necesito que me ayuden con este codigo yo tengo varios campos en php por ejemplo f y los m pero tengo ...
  #1 (permalink)  
Antiguo 30/07/2007, 12:08
 
Fecha de Ingreso: julio-2007
Mensajes: 114
Antigüedad: 16 años, 9 meses
Puntos: 0
De acuerdo Suma

buenas panas del foro necesito que me ayuden con este codigo yo tengo varios campos en php por ejemplo f y los m pero tengo que dar un total de los f y de los m y el ejemplo del escript es bueno para hacerlo pero cuando hago la suma me suma todos los f y los m como hago para que me sume los f y los m y despues me de un total le agradeceria que me ayuden porfa
  #2 (permalink)  
Antiguo 30/07/2007, 12:47
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Re: Suma

No te has explicado para nada. Por favor ve más despacio y pega algo de código que ayude a entender el problema.


Saludos.
  #3 (permalink)  
Antiguo 31/07/2007, 08:04
 
Fecha de Ingreso: julio-2007
Mensajes: 114
Antigüedad: 16 años, 9 meses
Puntos: 0
Re: Suma

vean yo necesito hacer una suma pero de varios campos tengo los campos f1,f2,f3,f4.... y tengo los campos m1,m2,m3,m4 y tengo que dar la sumatoria de todos los f y d todos los m y despues un total de la suma de todos los f y de todos los m

aqui esta todo el codigoo..

Código HTML:
<html>
<HEAD><style>
input{border:none;
border-bottom:solid 1px black;
font:normal 12px/12px 'courier new';
text-align:right;
}
td{font:normal 10px verdana;
padding:0px 20px 0px 0px;}
</style>
    <title>Untitled</title>
<script>
function sumar(){

ft=0;
for(a=0;a<34;a++){
document.forms[0].elements[a].value=document.forms[0].elements[a].value.split(",").join(".");
if (!isNaN(document.forms[0].elements[a].value)){
to=new Number(document.forms[0].elements[a].value);
ft=ft+to;
document.forms[0].elements["ft"].value=ft}
else{document.forms[0].elements[a].value=0}
}
}
</script><TITLE></TITLE></HEAD>
<BODY>
<TR>
<div align="center"><img src="imagenes/baner2.jpg" width="1106" height="144"></div>
<br>
<br>
<br>
<form action="matricula1.php" method="POST">
<table border = '3'>
<TR><TH colspan='80' bgcolor="Gray"> MATRICULA</TH></TR>
<TR bgcolor="Silver"><TH colspan='2'></TH>

<TH colspan='2'> FECHA DE INCORPORACION AL PROYECTO</TH>
<TH colspan='4'>TIPO DEL PLANTEL </TH>
<TH colspan='2'>DEPENDENCIA</TH>
<TH colspan='2'>ESPECIAL</TH>
<TH colspan='2'>INICIAL</TH>
<TH colspan='2'>PREES</TH>
<TH colspan='2'></TH>
<TH colspan='2'></TH>
<TH colspan='2'></TH>
<TH colspan='2'></TH>
<TH colspan='2'></TH>
<TH colspan='2'></TH>
<TH colspan='2'>1º AÑO</TH>
<TH colspan='2'>2º AÑO</TH>
<TH colspan='2'>3º AÑO</TH>
<TH colspan='3'>TOTALES</TH>
<TH colspan='4'>ESPECIALISTAS</TH>
<TH colspan='4'>PERSONAL</TH>
<TH colspan='5'>UBICACION GEOGRAFICA</TH></TR>
<TR bgcolor="Silver">
<TH>Municipio</TH><TH>Nombre_del_Plantel</TH><TH>MES</TH><TH>AÑO</TH><TH>UE</TH><TH>BAS</TH><TH>PREES</TH><TH>IEE</TH><TH>N</TH><TH>E</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>F</TH><TH>M</TH><TH>TOTAL</TH><TH>CULT</TH><TH>DEP</TH><TH>PSIC</TH><TH>TOTAL</TH><TH>DOC</TH><TH>ADM</TH><TH>OBR</TH><TH>TOTAL</TH><TH>R</TH><TH>F</TH><TH>I</TH><TH>U</TH><TH>OTRA</TH></TR></TR>
<TR bgcolor="Silver">
<TH><INPUT type="text" name="muni" size="20"></TH><TH><INPUT type="text" name="plantel"></TH><TH><INPUT type="text" name="mes"></TH><TH><INPUT type="text" name="ano" size="10" ></TH><TH><INPUT type="text" name="ue" size="2"></TH><TH><INPUT type="text" name="bas" size="2"></TH><TH><INPUT type="text" name="prees" size="2"></TH><TH><INPUT type="text" name="iee" size="2"></TH><TH><INPUT type="text" name="n" size="2"></TH><TH><INPUT type="text" name="f" size="2"></TH><TH><INPUT type="text" name="fe" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="me" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="fi" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="mi" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="fp" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="mp" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f1" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m1" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f2" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m2" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f3" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m3" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f4" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m4" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f5" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m5" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f6" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m6" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f11" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m11" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f22" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m22" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="f33" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="m33" size="2" onkeyup=sumar() ></TH><TH><INPUT type="text" name="ft" size="2"  readonly name="ft"></TH><TH><INPUT type="text" name="mt" size="2"></TH><TH><INPUT type="text" name="total" size="4"  readonly name="total"></TH><TH><INPUT type="text" name="cult" size="2"></TH><TH><INPUT type="text" name="dep" size="2"></TH><TH><INPUT type="text" name="psic" size="2"></TH><TH><INPUT type="text" name="total1" size="4"></TH><TH><INPUT type="text" name="doc" size="2"></TH><TH><INPUT type="text" name="adm" size="2"></TH><TH><INPUT type="text" name="obr" size="2"></TH><TH><INPUT type="text" name="total2" size="4"></TH><TH><INPUT type="text" name="r" size="2"></TH><TH><INPUT type="text" name="f" size="2"></TH><TH><INPUT type="text" name="i" size="2"></TH><TH><INPUT type="text" name="u" size="2"></TH><TH><INPUT type="text" name="otra" size="2"></TH></TR></TR>
</table>
</form>
</BODY>
</html> 

Última edición por tunait; 31/07/2007 a las 13:09 Razón: bbcode
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:11.