简体   繁体   English

jQuery:范围滑块:如何获取设置的范围值?

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

I want to get the set range values using $_POST after form submit. 我想在表单提交后使用$ _POST获得设置的范围值。 The problem is when range set to 10 - 25, value 10 is the only value got. 问题是,当范围设置为10-25时,唯一获得的值是10。

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. 确保滑块中具有isRange:true。 As mentioned in the docs: 文档中所述:

isRange : True if this is a range selector. isRange:如果这是范围选择器,则为True。 If its a range the value of hidden input will be set comma-seperated, eg, "25,75" 如果它是一个范围,则隐藏输入的值将设置为逗号分隔,例如“ 25,75”

You should get the two values if isRange is set to true. 如果isRange设置为true,则应该获得两个值。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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