2

Hope someone can help me, I am new to Jquery and this is the only thing I am still struggeling with. I have a slider with 3 textboxes, when sliding the slider it will auto populate the values to all three textboxes. I want the fourth textbox to add all of the values from the 3 textboxes that's already got the values.

I am getting the values using the following:

<script>
    $(function () {
        var sum = 0;
        $("#slider").slider({
            value: 2300,
            min: 500,
            max: 4500,
            step: 100,
            length: 300,
            slide: function (event, ui) {
                // Rule Calculation
                if (ui.value < 1000)
                    $("#amount3").val(ui.value * 0.15)
                else
                    $("#amount3").val(150)

                //10% Calculation
                if (ui.value > 1000)
                    $("#amount8").val(ui.value - 1000)
                else
                    $("#amount8").val(0)

                $("#amount").val("R" + ui.value)

                $("#amount9").val($("#amount8").val() * 0.10)
Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
Nicky
  • 21
  • 2

2 Answers2

0

I made something similar because I was looking for this functionality

http://jsbin.com/ojeruc/1/edit

Jay
  • 88
  • 3
0

I ammended your code to do what you asked. You can view it here:

http://jsfiddle.net/rLKbR/163/

You have to use 'parseInt($("#idOfTextbox"))' to convert each value in your textboxes to integers so they can be added, otherwise you will get a concatenation of the values as your result. Hopefully this has accomplished your needs :)

David Spence
  • 7,999
  • 3
  • 39
  • 63