1

I've got this script to calculate how much you can get with the amount you are donating.

$(function() {
    var ovalue = 65;
    var kann = 1;
    $("#slider").slider({
        value: ovalue,
        min: 65,
        max: 650,
        step: 65,
        slide: function(event, ui) {
            $("#amount").val(ui.value + " Euro");
            kann = ($("#slider").slider("option", "value") / ovalue >> 0);
            $("#kann").val(kann);
        }
    })
});

the variable kann represents the amount you can get.

At first, kann gets 1 as result because 65/65 is 1. If I move the slider kann should be 2. But 130/65 still is one, although the euro amount changes to 130€. 195€ is 2, etc.

If I am at 195€ and I go back to 130€ kann isn't 1 anymore (which is also false) but kann becomes 3...really? :)

1
  • no such thing as no floating point in js, js has no integer type Commented Aug 6, 2013 at 17:51

1 Answer 1

1

Just use ui.value http://jsfiddle.net/vXzp9/

.slider("option", "value") is always one step behind and is only set after "slide" event.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.