0

I am trying to replace a series of dropdowns with sliders. Everything seems to be working fine, however the sliders are acting very bizarre, not sure if it is because I have used a generic class rather than giving them all IDs?

Basically when I scroll a slider rather than the expected: 0,1,2,3 it is more along the lines of 1 first then 0 then 3 then 2...

Is this a simple case of incorrect setup or is it just not possible to use them in this way?

Thanks a lot, Anthony.

http://jsfiddle.net/Anth12/BnL93/1/

$(document).ready(function () {
    $('.DropDownToSlider').each(function () {
        var NewSlider = $(this).next(".DropDownSlider");

        var value = parseInt(NewSlider.text());
        $(this).val(value);
        NewSlider.text("");


        NewSlider.slider({
            value: value,
            min: 0,
            max: 3,
            slide: function (event, ui) {
                $(this).prev(".DropDownToSlider").val($(this).slider("value"));
                $(".SliderVal").text($(this).slider("value"));
            }
        });
    });
}); 
<select id="dd1" class="DropDownToSlider" style="">
    <option value="3">Admin</option>
    <option value="2">Basic</option>
    <option value="1">NoAuth</option>
    <option value="0">Delete</option>
</select>
<div id="ddslider1" class="DropDownSlider">1</div>
    <select id="dd2" class="DropDownToSlider" style="">
        <option value="3">Admin</option>
        <option value="2">Basic</option>
        <option value="1">NoAuth</option>
        <option value="0">Delete</option>
    </select>
<div id="ddslider2" class="DropDownSlider">2</div>
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Anth12
  • 1,869
  • 2
  • 20
  • 39

1 Answers1

1

Is that what you want to achieve? http://jsfiddle.net/7f53c/17/

    $('.DropDownToSlider').each(function () {
        var NewSlider = $(this).next(".DropDownSlider");

        var value = parseInt(NewSlider.text());
        $(this).val(value);
        NewSlider .text("");


        NewSlider.slider({
            value: value,
            min: 0,
            max: 3,
            slide: function (event, ui) {                
                //$(this).prev(".DropDownToSlider").val($(this).slider("value"));
                //$(".SliderVal").text($(this).slider("value"));
                $(".SliderVal").text(ui.value);
            }
        });
    });
kidwon
  • 4,448
  • 5
  • 28
  • 45
  • 1
    Perfect, Thank you. I didn't realize i was getting the value incorrectly. Thanks again. – Anth12 Dec 21 '12 at 13:38
  • OK, I saw that in my example dropdowns aren't changing but I could help with that either although I have the feeling you'll figure it out. Anyway feel free to ask me here :) – kidwon Dec 21 '12 at 13:41