我必須修理這個抵押計算器,但我真的不明白為什么計算不起作用。我需要幫助來解決這個問題。或者至少有人讓我了解這個功能有什么問題。(計算器輸入了申請人的合并年收入和存款的另一個輸入。計算器應顯示最大財產價值和估計每月成本的結果)。
function PMT (rate_per_period, number_of_payments, present_value, future_value, type ) {
var q = Math.pow(1 rate_per_period, number_of_payments);
return (rate_per_period * (future_value (q * present_value))) / ((-1 q) * (1 rate_per_period * (type)));
}
jQuery(document).ready(function ($) {
$(".input").keyup(function () {
var annualIncomeInput = 0;
var depositInput = 0;
var annualIncome = 0;
var deposit = 0;
var mortgage = 0;
var propertyValue = 0;
var monthlyPayments = 0;
annualIncomeInput = $('#annualIncome').val();
depositInput = $('#deposit').val();
annualIncome = parseFloat(annualIncomeInput.replace(/,/g, ''));
deposit = parseFloat(depositInput.replace(/,/g, ''));
if (annualIncomeInput && depositInput) {
if ((deposit / 0.1 - deposit) >= (annualIncome * 4.5)) {
mortgage = annualIncome * 4.5;
propertyValue = mortgage deposit;
} else {
propertyValue = deposit / 0.1;
mortgage = propertyValue - deposit;
}
monthlyPayments = PMT(0.0307/12, 30*12, mortgage, 0, 0).toFixed(2);
}
propertyValue = parseFloat(propertyValue).toLocaleString();
monthlyPayments = parseFloat(monthlyPayments).toLocaleString();
$('#totalHowMuchCanIBorrow').text('£' propertyValue);
$('#estimatedCosts').text('£' monthlyPayments);
})
})
如果您需要更多詳細資訊,請告訴我!謝謝!
uj5u.com熱心網友回復:
這可行,也許您可??以通過將其與您的錯誤進行比較來發現錯誤:) 沒有更改任何內容,只是向其中添加了合適的 html
function PMT(rate_per_period, number_of_payments, present_value, future_value, type) {
var q = Math.pow(1 rate_per_period, number_of_payments);
return (rate_per_period * (future_value (q * present_value))) / ((-1 q) * (1 rate_per_period * (type)));
}
jQuery(document).ready(function($) {
//not sure how your html looks but maybe here you want $("input") and not $(".input") that selects all elements with the css class input that's maybe missing in the html
$(".input").keyup(function() {
var annualIncomeInput = 0;
var depositInput = 0;
var annualIncome = 0;
var deposit = 0;
var mortgage = 0;
var propertyValue = 0;
var monthlyPayments = 0;
annualIncomeInput = $('#annualIncome').val();
depositInput = $('#deposit').val();
annualIncome = parseFloat(annualIncomeInput.replace(/,/g, ''));
deposit = parseFloat(depositInput.replace(/,/g, ''));
if (annualIncomeInput && depositInput) {
if ((deposit / 0.1 - deposit) >= (annualIncome * 4.5)) {
mortgage = annualIncome * 4.5;
propertyValue = mortgage deposit;
} else {
propertyValue = deposit / 0.1;
mortgage = propertyValue - deposit;
}
monthlyPayments = PMT(0.0307 / 12, 30 * 12, mortgage, 0, 0).toFixed(2);
}
propertyValue = parseFloat(propertyValue).toLocaleString();
monthlyPayments = parseFloat(monthlyPayments).toLocaleString();
$('#totalHowMuchCanIBorrow').text('£' propertyValue);
$('#estimatedCosts').text('£' monthlyPayments);
})
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="input" id='annualIncome' type="number">
<input class="input" id='deposit' type="number">
<div id="totalHowMuchCanIBorrow"></div>
<div id="estimatedCosts"></div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/367435.html
標籤:javascript 查询
上一篇:在TypeScript的介面中定義的可能呼叫簽名的更嚴格型別
下一篇:操縱元素之間的間距
