| |||
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 |
| |||
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'>1º</TH> <TH colspan='2'>2º</TH> <TH colspan='2'>3º</TH> <TH colspan='2'>4º</TH> <TH colspan='2'>5º</TH> <TH colspan='2'>6º</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 |