tags:

views:

1143

answers:

2

I have a JQuery slider that's working pretty well, but for some reason it's not passing the tenths value.

$(document).ready(function(){
     $("#scoreSlider").slider({
      'steps': 40,
      'min': 1.0, 
      'max': 5.0,
      'startValue': 3, 
      'slide': function(e, ui){ 
       document.getElementById('div_score').innerHTML = ui.value;
      }
     });        
});

It appears that there are the right number of clicks on the slider, but the passed value only has the whole number.

Any ideas.

+1  A: 

According to the documentation for Slider,

ui.value: Integer - the current handle's value

Why don't you change your code to this:

$(document).ready(function(){
    $("#scoreSlider").slider({
            'steps': 40,
            'min': 10, 
            'max': 50,
            'startValue': 30, 
            'slide': function(e, ui){ 
                    document.getElementById('div_score').innerHTML = ui.value/10.0;
            }
    });        
});

It seems to produce the decimal values that you desire.

Ben Koehler
I see that you already received this answer in the other question you asked at http://stackoverflow.com/questions/297245/jquery-slider-tutorials
Ben Koehler
Ya, thanks. I intended to update this question with the correct answer, but I got pulled into the code. Thanks for the help.
Ryan Smith
A: 

This was very helpful. In my case I'm dealing with minutes. Using the code above, how would I add a zero before a whole number (1-9) so I would get: 00 01 02 03, etc..

Bryan