Ver Mensaje Individual
  #14 (permalink)  
Antiguo 02/02/2011, 12:28
Avatar de SirDuque
SirDuque
 
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 10 meses
Puntos: 89
Respuesta: Crear funcion que sume todos los campos por ID [Asesoramiento]

ak dejo un html de como va este tema, con un copy paste puede ver el problema.

:(
Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <title>Documento sin t&iacute;tulo</title>
  4. <script>
  5. function totall(totallll){
  6. var cont = 0;
  7. for (i=1 ; i<document.forms[0].length ; i++){
  8.               if(document.forms[0].elements[i].value != ""){
  9.                        cont= cont+ document.forms[0].elements[i].value;
  10.                }
  11. }
  12. document.venta.total5.value=parseInt(cont);
  13. }
  14. </script>
  15. </head>
  16.  
  17. <body>
  18. <form name="venta">
  19. <table width="547">
  20.  
  21.  
  22.   <tr>
  23.     <td width="32"><input name="can1" type="text" id="can1" value="1" size="3" maxlength="2" autocomplete="off"/></td>
  24.     <td width="84"><input  name="cod1" type="text" id="cod1" size="14" maxlength="13" autocomplete="off" /></td>
  25.     <td width="330"><input  name="des1" type="text" id="des1" size="55" maxlength="50" autocomplete="off" readonly="readonly"/></td>
  26.     <td width="37"><input  name="uni1" type="text" id="uni1" size="6" maxlength="4" autocomplete="off" value="12" readonly="readonly"/></td>
  27.     <td width="40"><input  name="sub1" type="text" id="sub1" value="12" size="6" maxlength="5" readonly="readonly" autocomplete="off"/></td>
  28.   </tr>
  29.  
  30.     <tr>
  31.     <td><input  name="can2" type="text" id="can2" value="2" size="3" maxlength="2" autocomplete="off"/></td>
  32.     <td><input  name="cod2" type="text" id="cod2" size="14" maxlength="13" autocomplete="off"/></td>
  33.     <td><input  name="des2" type="text" id="des2" size="55" maxlength="50" autocomplete="off" readonly="readonly"/></td>
  34.     <td><input  name="uni2" type="text" id="uni2" size="6" maxlength="4" autocomplete="off" value="12" readonly="readonly"/></td>
  35.     <td><input  name="sub2" type="text" id="sub2" size="6" maxlength="5" value="24" readonly="readonly" autocomplete="off"/></td>
  36.   </tr>
  37.  
  38.     <tr>
  39.     <td><input  name="can3" type="text" id="can3" value="2" size="3" maxlength="2" autocomplete="off"/></td>
  40.     <td><input  name="cod3" type="text" id="cod3" size="14" maxlength="13" autocomplete="off"/></td>
  41.     <td><input  name="des3" type="text" id="des3" size="55" maxlength="50" autocomplete="off" readonly="readonly"/></td>
  42.     <td><input  name="uni3" type="text" id="uni3" size="6" maxlength="4" value="16" autocomplete="off"/></td>
  43.     <td><input  name="sub3" type="text" id="sub3" size="6" value="32" autocomplete="off"/></td>
  44.   </tr>
  45.  
  46.    <tr>
  47.     <td><input  name="can4" type="text" id="can4" size="3" maxlength="2" autocomplete="off"/></td>
  48.     <td><input  name="cod4" type="text" id="cod4" size="14" maxlength="13" autocomplete="off"/></td>
  49.     <td><input  name="des4" type="text" id="des4" size="55" maxlength="50" autocomplete="off" readonly="readonly"/></td>
  50.     <td><input  name="uni4" type="text" id="uni4" size="6" maxlength="4" autocomplete="off"/></td>
  51.     <td><input  name="sub4" type="text" id="sub4" size="6" value="0" autocomplete="off"/></td>
  52.   </tr>
  53.  
  54.    <tr>
  55.     <td><input  name="can5" type="text" id="can5" value="1" size="3" maxlength="2" autocomplete="off"/></td>
  56.     <td><input  name="cod5" type="text" id="cod5" size="14" maxlength="13" autocomplete="off"/></td>
  57.     <td><input  name="des5" type="text" id="des5" size="55" maxlength="50" autocomplete="off" readonly="readonly"/></td>
  58.     <td><input  name="uni5" type="text" id="uni5" size="6" maxlength="4" value="24" autocomplete="off"/></td>
  59.     <td><input  name="sub5" type="text" id="sub5" size="6" value="24" autocomplete="off"/></td>
  60.   </tr><tr>
  61.     <td></td>
  62.     <td></td>
  63.     <td></td>
  64.     <td></td>
  65.     <td><input type="text" name="total5" id="total5" size="6" value="0" autocomplete="off" readonly="readonly"/></td>
  66.   </tr>
  67. </table>
  68. <input type="button" name="button" id="button" onClick="totall(total5);" value="Calcular">
  69.  
  70. </form>
  71. </body>
  72. </html>
__________________
Mono programando!
twitter.com/eguimariano