简体   繁体   English

如何获取双精度范围选择器的选定值

[英]How to get selected value of double number range picker

I am using this range picker for my php project so there is value of selected range between 0 to 100 stored in database. 我正在为我的php项目使用此范围选择器,因此数据库中存储的选定范围的值介于0到100之间。

When page load than i was to set that database value in range picker and after submit button i was to save selected range between 0 to 100 in my database 当页面加载比我要在范围选择器中设置该数据库值时,在提交按钮后,我要在数据库中保存0到100之间的选定范围

How i can get & set value of range in rangepicker. 我如何获取和设置Rangepicker中的范围值。

html html

<div class="wrapper" style="width: 400px; margin: 100px auto; padding: 40px;">
  <div id="double_number_range" style="margin-top: 50px;"></div>
  <input type="submit">
</div>

js js

(function() {
  "use strict";
  $("#double_number_range").rangepicker({
    type: "double",
    startValue: 0,
    endValue: 100,
    translateSelectLabel: function(currentPosition, totalPosition) {
      return parseInt(100 * (currentPosition / totalPosition));
    }
  });
}());

fiddle 小提琴

Probably there will be better solutions using for example a callback function but you can use the following code too: 可能会有更好的解决方案,例如使用回调函数,但您也可以使用以下代码:

$("input[type=submit]").on('click', function() {
  var minValue = parseInt($('span.label.select-label:eq(1)').text(), 10);
  var maxValue = parseInt($('span.label.select-label:eq(0)').text(), 10);
  console.log(minValue, maxValue);
});

jsfiddle jsfiddle

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

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