DHTMLX Docs & Samples Explorer

Buttons Manipulations

The purpose of this sample is to show that you can affect any button's property with a script command.
Please remember that changing system buttons' state manually can cause their incorrect behaviour.

Select Button
Select Action
Source
<link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxwindows_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxwindows.js"></script>
 
<script src="../../codebase/dhtmlxcontainer.js"></script>
 
<div>
The purpose of this sample is to show that you can affect any button's property with a script command.
<br>
Please remember that changing system buttons' state manually can cause their incorrect behaviour.
</div>
<br>
<div>
<table>
    <tr>
        <td style="padding-right: 10px;">Select Button</td>
        <td>
            <select id="sel1">
                <option value="help">Help</option>
                <option value="stick,sticked">Stick</option>
                <option value="park">Park</option>
                <option value="minmax1,minmax2">Min/Max</option>
                <option value="close">Close</option>
            </select>
        </td>
    </tr>
    <tr>
        <td style="padding-right: 10px;">Select Action</td>
        <td>
            <select id="sel2">
                <optgroup label="visibility">
                    <option value="show">Show</option>
                    <option value="hide">Hide</option>
                    <option value="isHidden">isHidden</option>
                </optgroup>
                <optgroup label="access">
                    <option value="enable">Enable</option>
                    <option value="disable">Disable</option>
                    <option value="isEnabled">isEnabled</option>
                </optgroup>
            </select>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" style="padding-top: 10px; padding-bottom: 10px;"><input type="button" value="Apply" onclick="executeScript();"></td>
    </tr>
</table>
</div>
<div id="winVP" style="position: relative; height: 500px; border: #cecece 1px solid; margin: 10px;"></div>
<script>
var dhxWins,
w1;
function doOnLoad() {
    dhxWins = new dhtmlXWindows();
    dhxWins.enableAutoViewport(false);
    dhxWins.attachViewportTo("winVP");
    dhxWins.setImagePath("../../codebase/imgs/");
    w1 = dhxWins.createWindow("w1", 20, 30, 320, 240);
    w1.setText("dhtmlxWindow");
}
function executeScript() {
    if (dhxWins.window("w1") == null)
        return;
    var sel1 = document.getElementById("sel1");
    var btn = (sel1.options[sel1.selectedIndex].value).split(",");
    var sel2 = document.getElementById("sel2");
    var action = sel2.options[sel2.selectedIndex].value;
    if (btn.length == 2) {
        if (btn[0] == "stick")
            if (w1.isSticked())
            btn[0] = "sticked";
        if (btn[0] == "minmax1")
            if (w1.isMaximized())
            btn[0] = "minmax2";
    }
    switch (action) {
    case "show":
        w1.button(btn[0]).show();
        break;
    case "hide":
        w1.button(btn[0]).hide();
        break;
    case "isHidden":
        alert(w1.button(btn[0]).isHidden());
        break;
    case "enable":
        w1.button(btn[0]).enable();
        break;
    case "disable":
        w1.button(btn[0]).disable();
        break;
    case "isEnabled":
        alert(w1.button(btn[0]).isEnabled());
        break;
    }
}
</script>