Código:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> function sumcort() { sumlinea = 0 $(".sumlinea").each( function(index, value) { sumlinea = sumlinea + eval($(this).val()); } ); $("#total").val(sumlinea); } function nueva_linea() { $("#lineas").append('<input type="text" class="sumlinea" value="0"/><br/>'); } </script> </head> <body> <form method="POST" action="nada.html"> <div id="lineas"> <input type="text" class="sumlinea" value="0"/><br/> </div> <label for="total">Total: <input type="text" id="total" value="0"/><br/> <input type="button" value="Nueva línea" onclick="nueva_linea()"/> <input type="button" value="Calcular" onclick="sumcort()"/> </form> </body>