Calculation - How do i make a easy series of calculation?
Hello,
i made a calculation but i want to make the code easier because i want to extend it.
http://jsfiddle.net/HSTDL/
It is a calculation to determin how much money you made after x time when you ad y money on a regular basis of a quarter year. And each quarter you get the same yield.
$(document).ready(function(){
$(".divi").keyup(function(){
var val1 = +$(".betrag").val();
var val2 = +$(".quartal").val();
var val3 = +$(".nettodiv").val();
$("#result2").val((val1+val2)*(1+val3*0.712/100/4));
$("#result3").val(val3*0.712);
$("#result4").val((((val1+val2)*(1+val3*0.712/100/4))+val2)*(1+val3*0.712/100/4));
});
});
My problem is how do i make #result5 when i want to carry on the calculation. My current #result5 would be:
$("#result5").val((((((val1+val2)*(1+val3*0.712/100/4))+val2)*(1+val3*0.712/100/4))+val2)*(1+val3*0.712/100/4));
But when i want to calculate for 50 years it is another 200 result-lines and the code will explode in length. How can i make the string easier?
Second question:
How can i limit the #result fields to 2 digits after the point. Example 110.15€?
I appreciate your answers.