I am trying to create goal calculator where user enter future required amount and know how much monthly investment required.
Ex: If i want 1200 Rs after 1 year how much monthly investment required with compound.
HTML file here
<input type="number" id="goalAmt" placeholder="Goal Amount" required/>
<input type="number" id="goalYear" placeholder="Year" required/>
<input type="number" id="goanAnnualrate" placeholder="Annual Rate" required/>
<button id="submitBtn" onClick="GoalCalculate();">Submit</button>
I have written below javascript.
function GoalCalculate() {
var investment = parseInt(document.getElementById("goalAmt").value);
var annualRate =
parseInt(document.getElementById("goanAnnualrate").value);
var monthlyRate = annualRate / 12 / 100;
var years = parseInt(document.getElementById("goalYear").value);
var months = years * 12;
var futureValue = 0;
var goalVal = 0;
var currency = "INR";
goalVal = investment * (1 + monthlyRate) / (months);
document.getElementById("MI_req").innerHTML = currency + " "
(~~goalVal);
}