0

Hi I want to create some sliders, what i need to do is to make a slider which has 3 options in it:

  1. the amount the user wants to borrow (from 12,500 upto 100,000) - will display a value from where the selector is here
  2. over how long (from five yrs upto 25yrs) - will display a value from where the selector is here

  3. Estimate based on the values the monthly repayment.

i have looked at others on here but don't quite understand how they work logically so if anyone could help would be great.

I have added a quick image i made to dropbox: http://dl.dropbox.com/u/12506430/sliders.jpg

Graham Barnes
  • 235
  • 2
  • 6
  • 18

1 Answers1

0

Demo here.

<h2>How much would you like to borrow?</h2>
<div id="amount"></div>

<h2>Over how long?</h2>
<div id="period"></div>

<h2>Result</h2>
Your monthly payment will be $<span id="monthly">204.86</span>


function update() {
    var amount = $('#amount').slider('value');
    var period = $('#period').slider('value');
    var monthly = (amount + amount * 0.03 * period) / (period * 12);
    $("#monthly").text(monthly.toFixed(2));

}

$("#amount").slider({
    value: 12500,
    min: 12500,
    max: 100000,
    step: 50,
    slide: function() {
        update();
    }
});

$("#period").slider({
    value: 5,
    min: 5,
    max: 25,
    step: 1,
    slide: function() {
        update();
    }
});
Majid Fouladpour
  • 29,356
  • 21
  • 76
  • 127
  • hi thanks for that but i also need to show the current sliders amount for both: `$('#amount').slider('value'); $('#period').slider('value');` as per the slider image to the right of each slider, but am unsure how to do it? thanks. – Graham Barnes Oct 04 '11 at 18:32
  • Here is an update to display the current values: http://jsfiddle.net/majidf/wT7pF/ – Majid Fouladpour Oct 06 '11 at 10:52
  • thanks for doing that but unfortunately i need a bit more and this is where it gets quite complex: I have a spreadsheet: `http://dl.dropbox.com/u/12506430/LOAN%20CALC%20FIGURES.xlsx` so there are three sheets clean, middle and adverse I want that dependant on the credit rating it uses 1 of 3 sheets so if its good it uses the clean sheet and if you move the amount and years it would then get the data from this sheet, its immensely complex. – Graham Barnes Oct 08 '11 at 20:50
  • In that case you should change the `update` function and instead of having a single `monthly = formula` you have to put in a `if ... else` or a `switch ... case` and use the appropriate formula and/or coefficient for calculation of monthly paybacks. – Majid Fouladpour Oct 09 '11 at 07:58
  • would you be able to do it for me, I don't know enough jquery to do that as there is lots of data. – Graham Barnes Oct 09 '11 at 08:55