开发者

How to: 2 jQuery UI Slider 1.8.14

I'm trying to put two sliders in the same form ; but I can't manage to make the second one to work. Is it possible to have two sliders on the same page? And if it is, how should I do it?

Code used:

$(function() {
    $( "#slider-range" ).slider({
        range: true,
        min: 0,
        max: 2000000,
        values: [ 125000, 500000 ],
        slide: function( event, ui ) {
            //$( "#amount" ).val( "£" + ui.values[ 0 ] + " - £" + ui.values[ 1 ] );
            $( "#PriceMin" ).val( ui.values[ 0 ]);
            $( "#PriceMax" ).val( ui.values[ 1 ]);
            $("#amount").text("Price: £" + $("#slider-range").slider("values",0) + " - £" + $("#slider-range").slider("values",1));
        }
    });
    //$( "#amount" ).val( "£" + $( "#slider-range" ).slider( "values", 0 ) + " - £" + $( "#slider-range" ).slider( "values", 1 ) );
    $("#amount").text("Price: £" + $("#slider-range").slider("values",0) + " - £" + $("#slider-range").slider("values",1));

    $("#slider-range-rooms").slider({
        range: true,
        min: 0,
        max: 6,
        values: [ 1, 3 ],
        slide: function( event, ui ) {
            //$( "#rooms" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
            $( "#roomMin" ).val( ui.values[ 0 ]);
            $( "#roomMax" ).val( ui.values[ 1 ]);
            $("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) +开发者_开发百科 " - " + $("#slider-range-rooms").slider("values",1) );
        }
    });
    //$( "#rooms" ).val( $( "#slider-range-rooms" ).slider( "values", 0 ) + " - " + $( "#slider-range-rooms" ).slider( "values", 1 ) );     
    $("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );
});


I see a PHP concatenation in there. Try changing:

$("#rooms").text("Rooms: " . $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );

to

$("#rooms").text("Rooms: " + $("#slider-range-rooms").slider("values",0) + " - " + $("#slider-range-rooms").slider("values",1) );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜