<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>
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.


Sign In
Create Account


Back to top









