0

我有一个估算系统,允许我插入 html 代码。我们已经开始提供一些融资。我能够插入贷款计算器的代码,但我们知道贷款的长度、利率和估计的总金额。我需要弄清楚如何设置输入项,工作总数“{{charge.total | currency }}”是唯一的变量。我希望输出一个如下所示的句子(不是表格):

我们可以为您提供 132 个月的融资计划,年利率为 9.99%,这将使您每月还款接近$XXX.xx _ ____小字体

有人告诉我,堆栈溢出充满了喜欢小改动的聪明程序员。如果有人知道可以帮助解决此类小型编码问题的业务,我也会很高兴。

这是我尝试重新使用的代码:

<script language="JavaScript">
<!--
function showpay() {
 if ((document.calc.loan.value == null || document.calc.loan.value.length == 0) ||
     (document.calc.months.value == null || document.calc.months.value.length == 0)
||
     (document.calc.rate.value == null || document.calc.rate.value.length == 0))
 { document.calc.pay.value = "Incomplete data";
 }
 else
 {
 var princ = document.calc.loan.value;
 var term  = document.calc.months.value;
 var intr   = document.calc.rate.value / 1200;
 document.calc.pay.value = princ * intr / (1 - (Math.pow(1/(1 + intr), term)));
 }

// payment = principle * monthly interest/(1 - (1/(1+MonthlyInterest)*Months))

}

// -->
</script>

The results of this loan payment calculator are for comparison purposes only.
They will be a close approximation of actual loan
repayments if available at the terms entered, from a financial institution. This
is being
provided for you to plan your next loan application. To use, enter values
for the
Loan Amount, Number of Months for Loan, and the Interest Rate (e.g.
7.25), and
click the Calculate button. Clicking the Reset button will clear entered
values.
<p>
<center>
<form name=calc method=POST>
<table width=30% border=5>
<tr><th bgcolor="#aaaaaa" width=25%><font color=black>Description</font></th>
<th bgcolor="#aaaaaa" width=25%><font color=black>Data Entry</font></th></tr>
<tr><td bgcolor="#eeeee">Loan Amount</td><td bgcolor="#eeeee" align=right><input
type=text name=loan
size=10></td></tr>
<tr><td bgcolor="#eeeee">Loan Length in Months </td><td bgcolor="#eeeee"
align=right>(Terms 132mo 47mo 37mo)<input type=text
name=months size=3></td></tr>
<tr><td bgcolor="#eeeee">Interest Rate </td><td bgcolor="#eeeee" align=right>( Rates 9.99%  7.99% 5.99%)<input
type=text name=rate
size=3></td></tr>
<tr><td bgcolor="#eeeee">Monthly Payment</td><td bgcolor="#2E64FE"
align=right><em>Calculated</em> <input
type=text name=pay size=10></td></tr>
<tr><td  bgcolor="#eeeee"align=center><input type=button onClick='showpay()'
value=Calculate></td><td bgcolor="#eeeeee" align=center><input type=reset
value=Reset></td></tr>
</table>
</form>
<font size=1>Enter only numeric values (no commas), using decimal points
where needed.<br>
Non-numeric values will cause errors.</font>
</center>
4

1 回答 1

0

月度融资计划示例
欲了解更多信息,请访问我们的网站。

http://www.generation3electric.com/financing" target="_blank">www.GEN3Electric.com
**一个 ​​12 个月的融资计划,年利率为 0%,每月支付 {{ job.total | divide_by: 12| 货币 }}

window.onload = function showpay() {

var princ = "{{ job.total }}";

var term1 = 132;
var intr1 = 9.99 / 1200;
var intrrate1 = 9.99;

var term2 = 47;
var intr2 = 7.99 / 1200;
var intrrate2 = 7.99;

var term3 = 37;
var intr3 =5.99 / 1200;
var intrrate3 = 5.99;

var cost1 = princ * intr1 / (1 - (Math.pow(1 / (1 + intr1), term1)));
var cost2 = princ * intr2 / (1 - (Math.pow(1 / (1 + intr2), term2)));
var cost3 = princ * intr3 / (1 - (Math.pow(1 / (1 + intr3), term3)));
var payment1 = Math.round(cost1);
var payment2 = Math.round(cost2);
var payment3 = Math.round(cost3);
var content = "**A  " 
              + term1 
              + " month financing plan at " 
              + intrrate1 + "% APR that will give you a monthly payment close to $"
              + payment1 
              +".**<BR> **A "
              + term2 + " month financing plan at " 
              + intrrate2 + "% APR that will give you a monthly payment close to $"
              + payment2 + ".**<BR>**A  " 
              + term3 + " month financing plan at " + intrrate3 
              + "% APR that will give you a monthly payment close to $"
              + payment3
              + ".**<BR>"   ;
document.getElementById("financing").innerHTML = content;

;}

于 2013-10-20T22:42:46.027 回答