开发者

jQuery UI Range Slider values to input field

using the jQuery range slider i have been trying to get the values in a hidden input field which will be used for a search.

the hidden input field has the same id as the slider fields which the value but the hidden ones done show anything!

    $(document).ready(function() {
    $( "#sliderranger" ).slider({
        range: true,
        min: 0,
      开发者_C百科  max: 500,
        values: [ 75, 300 ],
        slide: function( event, ui ) {
            $( "#amount1" ).val( "THB " + ui.values[ 0 ] );
            $( "#amount2" ).val( "THB " + ui.values[ 1 ] );
            var price1 = ui.values[ 0 ];
            var price2 = ui.values[ 1 ];
            //alert(price1 + " " + price2); 
            $( "#price1" ).value = price1;
        }
    });
    $( "#amount1" ).val( "THB " + $( "#sliderranger" ).slider( "values", 0 ));
    $( "#amount2" ).val( "THB " + $( "#sliderranger" ).slider( "values", 1 ));
});

above is the js code if this helps if you need more info let me know and il see what i can do .

hope some one can help i can see much on this topic ??


the hidden input field has the same id as the slider fields which the value

I hope you don't mean that there are two elements with the same id attribute on the same page. If so, you'll need to change this or you'll see unexpected results.

As for setting the value of hidden inputs with slider results, it looks like you're close. This line:

$( "#price1" ).value = price1;

Should be changed to:

$( "#price" ).val(price1);

Here's your code revised (and using visible input elements of type text instead of hidden): http://jsfiddle.net/andrewwhitaker/Pyprr/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜