Hello i'm currently trying to develop a loan calculator which lets the user type in a loan amount, loan repyament per month and an interest rate. When the user clicks on the button i want it to display the term of the loan in years and months and the total interest to be paid. <html> <head> <title>Calculate Loan</title> <style type="text/css"> body { background-color: #000000; color: #FFFFFF; font-size: 30; text-align: center; } </style> <script type="text/javascript"> function calculate() { term = 0; totalInterest = 0; var amount, repayment, rate, monthInterest, term, totalInterest = parseFloat(document.frmLoan.txtLoanAmount.value) * parseFloat(document.frmrate.txtMonthlyRepayment.value), outstring; outstring = "$" + document.frmrate.txtRate.value + " payrate and " + document.frmrate.txtHrs.value + " hour(s) "; outstring = outstring + " means you earned $" + sum; document.getElementById('div1').innerHTML = outstring; } function clean() { //alert("in clean"); document.frmLoan.txtLoanAmount.value = ""; document.frmLoan.txtMonthlyRepayment.value = ""; document.frmLoan.txtInterestRate.value = ""; document.getElementById('div1').innerHTML = ""; document.frmLoan.txtLoanAmount.focus(); document.frmLoan.txtMonthlyRepayment.focus(); document.frmLoan.txtLoanAmount.focus(); document.frmLoan.txtLoanAmount.focus(); } </script> </head> <body onload="window.document.frmLoan.txtLoanAmount.focus()"> <h1>Calculate Loan</h1> <form name="frmLoan"> Enter loan amount : <input type="text" name="txtLoanAmount"> <br /><br /> Enter loan repayment amount per month : <input type="text" name="txtMonthlyRepayment"> <br /><br /> Enter interest rate : <input type="text" name="txtInterestRate"> <br /><br /> </form> <br /> <br /> <input type="button" name="cmdcalculate" value="Calculate term of loan and total interest" onclick="calculate()" /> <input type="button" name="cmdClear" value="Reset" onClick="clean()"> <br /><br /><br /> <div id="div1"></div> </body> </html> Code (markup): That is my code so far i'm not sure what i'm doing wrong but if anyone could help me that would be great. Cheers.
Hi! Too Many Values Are Missing... frmrate Is Missing document.frmrate.txtMonthlyRepayment.value txtRate Field Is Missing document.frmrate.txtRate.value txtHrs Field Is Missing document.frmrate.txtHrs.value And Where Are U Using "totalInterest" In "outstring"? totalInterest = parseFloat(document.frmLoan.txtLoanAmount.value) * parseFloat(document.frmrate.txtMonthlyRepayment.value); outstring = "$" + document.frmrate.txtRate.value + " payrate and " + document.frmrate.txtHrs.value + " hour(s) "; outstring = outstring + " means you earned $" + sum; So Complete Your Code Then RUN.