js 代码问题 求解,在线等
<html><title>JavaScriptLoanCalculator</title><head><style>.result{font=weight:bold;}#...
<html>
<title>JavaScript Loan Calculator</title>
<head>
<style>
.result {font=weight:bold;}
#payment(text=decoration:underline;)
</style>
</head>
<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)Anumal 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 payment:</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 calculate(){
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.getElenmentById("totalinterest");
if (isFinite(monthly)){
payment.innerHTML=monthly.toFixed(2);
total.innerHTML=(mounthly*payments).toFixed(2);
totalinterest.innerHTML=((monthly*payments)-principal).toFixed(2);
else
{
payment.innerHTML="";
total.innerHTML="";
totalinterest.innerHTML="";
}
}
</script>
</body>
</html>
想完成如图效果 展开
<title>JavaScript Loan Calculator</title>
<head>
<style>
.result {font=weight:bold;}
#payment(text=decoration:underline;)
</style>
</head>
<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)Anumal 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 payment:</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 calculate(){
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.getElenmentById("totalinterest");
if (isFinite(monthly)){
payment.innerHTML=monthly.toFixed(2);
total.innerHTML=(mounthly*payments).toFixed(2);
totalinterest.innerHTML=((monthly*payments)-principal).toFixed(2);
else
{
payment.innerHTML="";
total.innerHTML="";
totalinterest.innerHTML="";
}
}
</script>
</body>
</html>
想完成如图效果 展开
展开全部
改好了
<html>
<title>JavaScript Loan Calculator</title>
<head>
<style>
.result {font=weight:bold;}
#payment(text=decoration:underline;)
</style>
<script type="text/javascript">
function calculate(){
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>
</head>
<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)Anumal 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 payment:</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>
</body>
</html>
<html>
<title>JavaScript Loan Calculator</title>
<head>
<style>
.result {font=weight:bold;}
#payment(text=decoration:underline;)
</style>
<script type="text/javascript">
function calculate(){
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>
</head>
<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)Anumal 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 payment:</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>
</body>
</html>
追问
你改的很好 能告诉我错在那里了吗 我自己对了几边 我的还是找不到错误,向你 请教
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询