I'm not very good at debugging although I've gone over it till by eyes started bleeding. It seems right but its not even calculating onClick??
Could someone tell me where I went wrong so I know?
INVESTMENT
Create an application that allows a Customer to enter an initial deposit (for example $100), an annual interest rate (say 12%, which is 1% per month) and a target savings amount (say $200). Determine how many months it will take for the customer to reach this target amount.
Save your program as investment.htm
what i've done:
HTML Code:<html> <head></head> <body> <script type="text/javascript"> function calc(){ var deposit = parseFloat(document.form_invest.deposit.value); var percent = parseFloat(document.form_invest.percent.value)/12/100; var target = parseFloat(document.form_invest.target.value); var months = 0; if (deposit < target){ deposit = deposit + deposit * percent; months++; } document.getElementById("disp").innerHTML = "Your investment will take " + parseFloat(months) + " months to reach your target amount."; } </script> <center> <form name="form_invest"> <table class="text" cellpadding="5"> <tr> <td colspan="2" align="center"><b style="color:red">How much will you invest?</b></td> <tr> <td align="right">Deposit: </td><td><input type="text" name="deposit" size="3"></td> </tr> <tr> <td align="right">Iterest Rate:</td><td><input type="text" name="percent" size="3">% </td> </tr> <tr> <td align="right">Target Amount:</td><td><input type="text" name="target" size="3"></td> </tr> <tr> <td colspan="2" align="center"><input type="button" value="Calculate" onClick="calc"></td> <tr> <tr> <td colspan="2" align="center"><div id="disp" style="color:#ffffff;"></div></td> <tr> </table> </form> </center> </body> </html>


LinkBack URL
About LinkBacks
Reply With Quote


