DHTMLX Docs & Samples Explorer

### Slider Value

| Current Value: | Value:
Minimal Value: | Value: Label:
Maximal Value: | Value: Label:

Source

    <script type="text/javascript" src="../../codebase/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../../codebase/dhtmlxtoolbar.js"></script>
    <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxtoolbar_dhx_skyblue.css"></link>

    <div id="toolbarObj"></div>
    <div style="margin-top: 20px;">
    <table cellspacing="0" cellpadding="2" border="0">
        <tr>
            <td rowspan="3"><select id="sel"></select></td>
            <td style="padding-left: 5px; padding-right: 5px;">Current Value:</td>
            <td>
                <input type="button" value="Get Value" onclick="getValue();">
                <input type="button" value="Set Value" onclick="setValue();">
                Value:
                <input id="txt" type="text" value="50" style="width: 30px;">
            </td>
        </tr>
        <tr>
            <td style="padding-left: 5px; padding-right: 5px;">Minimal Value:</td>
            <td>
                <input type="button" value="Get Value" onclick="getMinValue();">
                <input type="button" value="Set Value" onclick="setMinValue();">
                Value:
                <input id="txtmin1" type="text" value="10" style="width: 30px;">
                Label:
                <input id="txtmin2" type="text" value="Min" style="width: 60px;">
            </td>
        </tr>
        <tr>
            <td style="padding-left: 5px; padding-right: 5px;">Maximal Value:</td>
            <td>
                <input type="button" value="Get Value" onclick="getMaxValue();">
                <input type="button" value="Set Value" onclick="setMaxValue();">
                Value:
                <input id="txtmax1" type="text" value="100" style="width: 30px;">
                Label:
                <input id="txtmax2" type="text" value="Max" style="width: 60px;">
            </td>
        </tr>
    </table>
    </div>
    <script>var sel = document.getElementById("sel");
    var toolbar = new dhtmlXToolbarObject("toolbarObj");
    toolbar.setIconsPath("../common/imgs/");
    toolbar.loadXML("../common/dhxtoolbar_slider.xml?etc=" + new Date().getTime(), updateList);
    function getId() {
        var id = sel.options[sel.selectedIndex].value;
        return id;
    }
    function setValue() {
        toolbar.setValue(getId(), Number(document.getElementById("txt").value));
    }
    function getValue() {
        alert(toolbar.getValue(getId()));
    }
    function setMinValue() {
        var t = String(document.getElementById("txtmin2").value);
        var v = Number(document.getElementById("txtmin1").value);
        toolbar.setMinValue(getId(), v, t);
    }
    function getMinValue() {
        alert(toolbar.getMinValue(getId()));
    }
    function setMaxValue() {
        var t = String(document.getElementById("txtmax2").value);
        var v = Number(document.getElementById("txtmax1").value);
        toolbar.setMaxValue(getId(), v, t);
    }
    function getMaxValue() {
        alert(toolbar.getMaxValue(getId()));
    }
    function updateList() {
        sel.options.length = 0;
        toolbar.forEachItem(function(itemId) {
            if (toolbar.getType(itemId) == "slider") {
                sel.options.add(new Option(itemId, itemId));
            }
        });
    }</script>