Loan Interest rate calculator code -html code with java script - Free html code for
Here is a code for loan interest calculator online
<head>
<meta charset="UTF-8"></meta>
<meta content="width=device-width, initial-scale=1.0" name="viewport"></meta>
<title>Interest Rate Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 20px 0;
padding: 20px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 15px;
}
label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
input {
width: calc(100% - 16px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-top: 8px;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#result {
text-align: center;
margin-top: 15px;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Interest Rate Calculator</h1>
<form id="interestRateCalculatorForm">
<label for="loanAmount">Loan Amount:</label>
<input id="loanAmount" placeholder="Loan amount" required="" type="number" />
<label for="loanTenure">Loan Tenure (months):</label>
<input id="loanTenure" placeholder="Loan tenure" required="" type="number" />
<label for="monthlyInstallment">Monthly Installment:</label>
<input id="monthlyInstallment" placeholder="Monthly installment" required="" type="number" />
<input id="calculateBtn" type="submit" value="Calculate" />
</form>
<div id="result"></div>
<script>
document.getElementById('interestRateCalculatorForm').addEventListener('submit', function (event) {
event.preventDefault();
calculateInterestRate();
});
function calculateInterestRate() {
var loanAmount = parseFloat(document.getElementById('loanAmount').value);
var loanTenure = parseFloat(document.getElementById('loanTenure').value);
var monthlyInstallment = parseFloat(document.getElementById('monthlyInstallment').value);
var interestRate = ((monthlyInstallment * loanTenure) / loanAmount) * (12 / loanTenure) * 100;
var resultElement = document.getElementById('result');
resultElement.innerHTML = "Interest Rate: " + interestRate.toFixed(2) + "%";
}
</script>
</body>
</html>
Comments
Post a Comment