Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Larry on Dec 03, 2008 08:17
open dhtmlx forum
Slider Pointer Increment Size

I would like to use the Slider as a pointing device for text wither within a TextBox or against free Text.
In this case as a character counter. I'd like the spacing to match of course.

<div id="a1">Slider value is 1</div>
<script>
    //slider onChange handler
    function my_func(pos,slider){
        document.getElementById("a1").innerHTML="Slider value is "+pos;
    }    
    var slider=new dhtmlxSlider(null, 500);
    slider.attachEvent("onChange",my_func);
    slider.setSkin("arrow");
    slider.setMin(1);
    slider.init();
</script>
   <input id="input1" size=50 style="font-family:'Courier New', Courier, mono;font-size:10px;" type="text" value='1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'>

Likely I will need to use a fixed-font in the HTML text. But can the Slider's pointer increment size be fixed as well (to match)?
Can this be done reliably?
Answer posted by Support on Dec 04, 2008 01:55
>>But can the Slider's pointer increment size be fixed as well
You can define "step" size for the slider, so slider will round any value to the steps

slider.setStep(8);
slider.setValue(63)
alert(slider.getValue()) // 64 <= rounded to step size