... I just dont get it im trying to make the Interest from a slider that shows in the HTML to a set value thats added onto the total money to be lent
Here the JQuery code I have
and the HTML side
It displays like below... But I want the interest slider gone yet still effective to the sum but a set value like a percentage (APR which will be set later on)
I need the Interest to be a Variable with a set value (which will be a percentage) the percentage will come from the money and time slider values then get added to the total/result at the bottom of the form but I dont need it displayed on the form if that makes sense?
Cheers guys!
Nick
Here the JQuery code I have
Code:
// JavaScript Document
$(function() {
$( "#amount_slider" ).slider({
orientation: "horizontal",
range: false,
min: 1000,
max: 300000,
value: 100000,
step: 1000,
slide: function( event, ui ) {
$( "#amount" ).text( ui.value );
},
stop: function( event, ui ) {
calculateMorgage();
}
});
$( "#amount" ).text($( "#amount_slider" ).slider( "value" ));
$( "#interest_slider" ).slider({
orientation: "horizontal",
range: false,
min: 6,
max: 6,
value: 6,
step: 0.25,
slide: function( event, ui ) {
$( "#interest" ).text( ui.value );
},
stop: function( event, ui ) {
calculateMorgage();
}
});
$( "#interest" ).text($( "#interest_slider" ).slider( "value" ));
$( "#time_slider" ).slider({
orientation: "horizontal",
range: false,
min: 1,
max: 30,
value: 15,
slide: function( event, ui ) {
$( "#time" ).text( ui.value );
},
stop: function( event, ui ) {
calculateMorgage();
}
});
$( "#time" ).text($( "#time_slider" ).slider( "value" ));
function calculateMorgage() {
var amount = $( "#amount_slider" ).slider( "value" );
var interest = $( "#interest_slider" ).slider( "value" ) / 1200;
var time = $( "#time_slider" ).slider( "value" ) * 12;
var rate = amount * (interest * Math.pow(1+interest,time)) / (Math.pow(1+interest,time)-1);
$( "#result" ).text(rate.toFixed(2));
}
calculateMorgage();
});
and the HTML side
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript" src="slider.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="jquery-ui-1.8.20.custom.css">
<style type="text/css">
#amount_slider, #interest_slider, #time_slider {
width: 200px;
margin-top: 20px;
float: left;
}
#amount, #interest, #time, #result {
margin-left: 20px;
margin-top: 20px;
float: left;
}
#result {
font-weight: bold;
}
.message {
float: left;
margin-top: 20px;
font-family:Arial;
width: 100px;
}
.clear {
clear: both;
}
.background-wrapper {
border: #a6c9e2 solid 1px;
width: 500px;
text-align: center;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="background-wrapper">
<div class="message">Amount</div>
<div id="amount_slider"></div>
<div id="amount"></div>
<div class="clear"></div>
<div class="message">Interest</div>
<div id="interest_slider"></div>
<div id="interest"></div>
<div class="clear"></div>
<div class="message">Time (years)</div>
<div id="time_slider"></div>
<div id="time"></div>
<div class="clear"></div>
<div class="message">Monthly payment</div>
<div id="result"></div>
<div class="clear"></div>
</div>
</body>
</html>
It displays like below... But I want the interest slider gone yet still effective to the sum but a set value like a percentage (APR which will be set later on)
I need the Interest to be a Variable with a set value (which will be a percentage) the percentage will come from the money and time slider values then get added to the total/result at the bottom of the form but I dont need it displayed on the form if that makes sense?
Cheers guys!
Nick