The Loan-to-Value (LTV) ratio is a financial metric used by lenders to assess the risk of a loan, particularly in real estate transactions. It compares the loan amount to the appraised value or purchase price of the property, whichever is lower. A lower LTV generally indicates a lower risk for the lender and can result in better loan terms for the borrower.
function calculateLTV() {
var loanAmountInput = document.getElementById("loanAmount");
var propertyValueInput = document.getElementById("propertyValue");
var resultDiv = document.getElementById("result");
var loanAmount = parseFloat(loanAmountInput.value);
var propertyValue = parseFloat(propertyValueInput.value);
if (isNaN(loanAmount) || isNaN(propertyValue)) {
resultDiv.innerHTML = "Please enter valid numbers for both fields.";
return;
}
if (propertyValue <= 0) {
resultDiv.innerHTML = "Property value must be greater than zero.";
return;
}
var ltvRatio = (loanAmount / propertyValue) * 100;
resultDiv.innerHTML = "The Loan-to-Value (LTV) Ratio is: " + ltvRatio.toFixed(2) + "%";
}
#loan-to-value-calculator {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 400px;
margin: 20px auto;
background-color: #f9f9f9;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
#loan-to-value-calculator button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
#loan-to-value-calculator button:hover {
background-color: #45a049;
}