Hi Guys, im making a investment loop where you enter a initial deposit say $100,plus a annual intrest rate say 12% and a target amount that the user wishes to reach say $200 then calculate those amounts to display the exact month/months it will take to reach the target.
here is my code:
CODE
<script type="text/javascript">
function calculate() {
initialdeposit = parseInt (document.input.initialdeposit.value)
annualrate = parseInt (document.input.annualrate.value)
targetsavings = parseInt (document.input.targetsavings.value)
monthlyrate = (annualrate / 12) / 100
do {
answer = initialdeposit * monthlyrate
} while (answer == targetsavings)
document.output.result.value = answer
}
</script>
</head>
<h1>Investment</h1>
<form name="input">
Please enter your initial deposit:
<input type="text" name="initialdeposit">
<br />
Please enter your annual interest rate:
<input type="text" name="annualrate">
<br />
Please enter your target savings amount:
<input type="text" name="targetsavings">
<br />
<input type="button" value="Calculate" onClick="calculate()">
</form>
<form name="output">
It will take
<input type="text" name="result">month/s to reach your target amount.
</form>
</body>
</html>
hope you guys can help me or eplain what i need to do to get it to work.
Cheers Randall.