避免在dijit / form / Horizo​​ntalSlider中使用十进制值

时间:2013-04-05 12:21:24

标签: javascript slider dojo

在变更dijit/form/HorizontalSlider中,我在文本框中获取值。值为十进制,如51.66777777。我只想要51

<div id="horizontalSlider"></div>
<input type="text" id="sliderValue" data-dojo-type="dijit.form.TextBox" style="width:190px;" onkeyup="getSliderTxtBoxValue();">

var slider = new HorizontalSlider({
                    name: "horizontalSlider",
                    value: 1,
                    minimum: 1,
                    maximum: 500,
                    discreteValues: 10,
                    intermediateChanges: true,
                    style: "width:200px;",
                    onChange: function(value){
                        dom.byId("sliderValue").value = value;
                    }
                }, "horizontalSlider");
  

另见:

     

http://dojotoolkit.org/reference-guide/1.8/dijit/form/HorizontalSlider.html

1 个答案:

答案 0 :(得分:3)

你见过Spinal Tap吗?这个去了11!

以下是可行的代码:

value: 0,
minimum: 0,
maximum: 500,
discreteValues: 11,

你想要11因为你想要11个离散值:

0,50,100,150,200,250,300,350,400,450,500

我创建了 fiddle for this problem