滑动时,我无法从价格范围滑块读取值

时间:2012-03-30 06:20:10

标签: javascript jquery

我如何阅读minValue&包括maxValue

<link rel="stylesheet" href="<?=base_url()?>javascripts/slider/jquery.ui.all.css">
<script src="<?=base_url()?>javascripts/slider/jquery-1.7.1.js"></script>
<script src="<?=base_url()?>javascripts/slider/jquery.ui.widget.js"></script>
<script src="<?=base_url()?>javascripts/slider/jquery.ui.mouse.js"></script>
<script src="<?=base_url()?>javascripts/slider/jquery.ui.slider.js"></script>
<form name="formList" id="formList" method="POST" action="<?php echo site_url();?>/hotels/search" enctype="multipart/form-data">
<script>
    $(function () {
        $("#slider-range").slider({
            range: true,
            min: 0,
            max: 1000,
            values: [100, 1000],
            slide: function (event, ui) {
                $("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
            }
        });
        $("#amount").val("$" + $("#slider-range").slider("values", 0) +
            " - $" + $("#slider-range").slider("values", 1));

        $("#minValue").val(ui.values[0]);
        $("#maxValue").val(ui.values[1]);
    });
</script>
<div class="left" id="leftSlider">
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
<!-- <div id="range">Price Range <span id="amount"></span></div>
    <div id="slider"></div>-->
<div id="slider-range"></div>

1 个答案:

答案 0 :(得分:0)

您希望您的逻辑位于幻灯片的功能中:

$(function() {
    $( "#slider-range" ).slider({
        range: true,
        min: 0,
        max: 1000,
        values: [ 100, 1000 ],
        slide: function( event, ui ) {

            $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
        " - $" + $( "#slider-range" ).slider( "values", 1 ) );

        $( "#minValue" ).val( ui.values[ 0 ] );
        $( "#maxValue" ).val( ui.values[ 1 ] );

        }
    });

});