Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions VehicleLoanCalculator/Johnn222/calculator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body{
padding:20px;
}

#loanCalc input{
padding:10px;
display:block;
}


.paymentCalc{
background-color: #f7f7f7;
border: 1px solid #d3d3d3;
padding: 35px 35px;
overflow: auto;
position: relative;
left: 220;
width:fit-content;
justify-content: center;
}

.calcBtn{
display:inline-block;
background:#c62233;
color:#fff;
text-align:center;
padding:10px 20px;
border-radius: 3px;

}

#paymentResults{
display: none;
background:#fff;
padding: 30px 60px 36px 60px;
border:1px solid lightgrey;
margin-top:88px;
}

.output{
text-shadow: 2px;
font-weight: bold;
font-size: large;
width: 170;
align-items: flex-end;
text-align: right;
}

label{
font-size: medium;
}


46 changes: 46 additions & 0 deletions VehicleLoanCalculator/Johnn222/calculator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function calculatePayments(){
var vehiclePrice = document.getElementById('vehiclePrice').value,
loanTerm = document.getElementById('loanTerm').value,
intRate = document.getElementById('intRate').value,
downPayment = document.getElementById('downPayment').value,
tradeValue = document.getElementById('tradeValue').value,
amount = parseInt(vehiclePrice),
months = parseInt(loanTerm),
down = parseInt(downPayment),
trade = parseInt(tradeValue),
totalDown = down + trade
annInterest = parseFloat(intRate),
monInt = annInterest / 1200;

if(!amount){
alert('Please add a loan amount');
return;
}

if(!months){
months = 60;
loanTerm = document.getElementById('loanTerm').value = '60';
}

if(!downPayment){
down = 0;
downPayment = document.getElementById('downPayment').value = '0';
}

if(!trade){
trade = 0;
tradeValue = document.getElementById('tradeValue').value = '0';
}

if(!annInterest){
annInterest = 3.25;
intRate = document.getElementById('intRate').value = '3.25';
}


var calc = ((monInt + (monInt / (Math.pow((1 + monInt), months) -1))) * (amount - (totalDown || 0))).toFixed(2);
var total = (calc * months).toFixed(2);
document.getElementById("MonthlyPayment").value = calc;
document.getElementById("TTLPayment").value = total;

}
71 changes: 71 additions & 0 deletions VehicleLoanCalculator/Johnn222/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<html>
<head>
<title>Loan Calculator</title>
<link rel="stylesheet" href="calculator.css">
</head>
<body>
<div class="col-md-12 paymentCalc">

<form id="loanCalc" onsubmit="return false">
<div class="col-md-12">
<h2>Loan Calculator</h2>
<div class="form-group">
<label for="vehiclePrice">Vehicle Price ($)</label>
<input type="text" onfocus="this.value=''" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" id="vehiclePrice" placeholder="Vehicle Price">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="downPayment">Down Payment ($)</label>
<input type="text" onfocus="this.value=''" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" id="downPayment" placeholder="Down Payment" value="0">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="tradeValue">Trade In Value ($)</label>
<input type="text" onfocus="this.value=''" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" id="tradeValue" placeholder="Trade In Value" value="0">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="intRate">Interest Rate</label>
<input type="text" onfocus="this.value=''" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" id="intRate" placeholder="Interest Rate" value="3.25">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="loanTerm">Loan Term (Month)</label>
<input type="text" onfocus="this.value=''" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" id="loanTerm" placeholder="Loan Term (ex: 36 Months)">
</div>
</div>
<br/>
<div class="submit"></div>
<div class="col-md-12">
<input type="submit" class="calcBtn" onclick="calculatePayments()" id="calculate" value="Calulate">
</div>
<br/>
<div>
<table>
<tr>
<td>
<label for="output">Monthly Payment ($)</label>
<input type="text" class ="output" id="MonthlyPayment" disabled>
</td>
</tr>
<tr>
<td>
<label for="output">Total Payment ($)</label>
<input type="text" class ="output" id="TTLPayment" disabled>
</td>
</tr>
</table>
</div>
</form>

</div>


</div>
<script src="/calculator.js"></script>
</body>
</html>