0

I'm building a finance calculator with jQuery which is working well. The calculator uses jQuery sliders. I have the following function which is called when a slider is activated.

However I need to replicate this so the same actions are called on page load, could anyone suggest how I might achieve this?

jQuery(document).ready(function($) {
    $("#slider-deposit").slider({
        value: 100,
        min: <?php echo json_encode($minDeposit); ?>,
        max: <?php echo json_encode($maxDeposit); ?>,
        step: 1,
        slide: function(event, ui) {
            $("#amount-deposit").val(Number(ui.value).toFixed(2));
            totalPayableFunc();
            monthlyPaymentsFunc();
        }
    });
    $("#amount-deposit").val("" + $("#slider-deposit").slider("value"));
});
5
  • You are doing right, but what is the issue you are facing? Any error(s) in the console. Commented Jan 6, 2016 at 11:26
  • What excatly do you want it to happen on page load? Commented Jan 6, 2016 at 11:32
  • 1
    just call the function totalPayableFunc();monthlyPaymentsFunc(); right after $("#amount-deposit").val("" + $("#slider-deposit").slider("value")); i.e. last line of above code. Commented Jan 6, 2016 at 11:34
  • Essentially I need to call the two functions, totalPayableFunc(); and monthlyPaymentsFunc(); Commented Jan 6, 2016 at 11:34
  • You need to call the functions on pageload right? Commented Jan 6, 2016 at 11:36

1 Answer 1

1

Is it this?

jQuery(document).ready(function($) {
    $("#slider-deposit").slider({
        value: 100,
        min: <?php echo json_encode($minDeposit); ?>,
        max: <?php echo json_encode($maxDeposit); ?>,
        step: 1,
        slide: function(event, ui) {
            $("#amount-deposit").val(Number(ui.value).toFixed(2));
            totalPayableFunc();
            monthlyPaymentsFunc();
        }
    });
    $("#amount-deposit").val("" + $("#slider-deposit").slider("value"));
    totalPayableFunc();
    monthlyPaymentsFunc();
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.