简体   繁体   中英

Jquery: Range Slider: How to get the set range values?

I want to get the set range values using $_POST after form submit. The problem is when range set to 10 - 25, value 10 is the only value got.

if(isset($_POST['btn_submit']))
{
   $value = $_POST['get'];
   echo "<script> alert($value) </script>";
}

<form method="post">
    <input class="range-slider" type="hidden" name="get"/>
    <input type="submit" value="Submit" name="btn_submit">
</form>

  $(document).ready(function(){
    $('.single-slider').jRange({
        from: -2.0,
        to: 2.0,
        step: 0.5,
        scale: [-2.0,-1.0,0.0,1.0,2.0],
        format: '%s',
        width: 300,
        showLabels: true,
        snap: true
    });

    $('.range-slider').jRange({
        from: 0,
        to: 100,
        step: 1,
        scale: [0,25,50,75,100],
        format: '%s',
        width: 300,
        showLabels: true,
        isRange : true
    });
});

Make sure you have isRange: true in the slider. As mentioned in the docs:

isRange : True if this is a range selector. If its a range the value of hidden input will be set comma-seperated, eg, "25,75"

You should get the two values if isRange is set to true.

您可以使用汇入两个输入框,第一个用于起始范围,第二个用于结束范围并采用值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM