日期:2014-05-16  浏览次数:20388 次

请教错在哪里了,为什么运行不了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style>
/* This is a CSS style sheet:it adds style to the program output */
.result { font-weight:bold;}
#payment { text-decoration:underline;}
</style>
<body>
<form name="loandata">
<table>
<tr><td><b>Enter Loan Information:</b></td></tr>
<tr>
<td>1)Amount of the loan(any currency):</td>
<td><input type="text" name="principal" onchange="calculate();" /></td>
</tr>
<tr>
<td>2)Annual percentage rate of interest:</td>
<td><input type="text" name="interest" onchange="calculate();" /></td>
</tr>
<tr>
<td>3)Repayment period in years:</td>
<td><input type="text" name="years" onchange="calculate();" /></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Compute" onclick="calculate();" /></td></tr>
<tr><td><b>Payment Information:</b></td></tr>
<tr>
<td>4)Your monthly payment:</td>
<td>$<span class="result" id="payment"></span></td>
</tr>
<tr>
<td>5) Your total interest payments:</td>
<td>$<span class="result" id="total"></span></td>
</tr>
<tr>
<td>
6)Your total interest payments:</td>
<td>$<span class="result" id="totalinterest"></span></td>
</tr>
</table>
</form>
<script language="javascript">
function aclculate(){
var principal= document.loandata.principal.value;
var interest = document.loandata.interest.value / 100 / 12;
var payments = document.loandata.years.value * 12;
var x = Math.pow(1 + interest,payments);
var monthly = (principal*x*interest)/(x-1);
var payment = document.getElementById("payment");
var total = document.getElementById("total");
var totalinterest = document.getElementById("totalinterest");
if (isFinite(monthly)){
payment.innerHTML = monthly.toFixed(2);
total.innerHTML = (monthly * payments).toFixed(2);
totalinterest.innerHTML = ((monthly*payments)-principal).toFixed(2);
}
else {
payment.innerHTML = "";
total.innerHTML = "";
totalinterest.innerHTML = "";
}
}
</script>
</body>
</html>


------解决方案--------------------
function aclculate(){
<td><input type="text" name="principal" onchange="calculate();" /></td>
自己看看。。这中低级错误