DHTMLX Docs & Samples Explorer

### Showing Hiding Items

Select Item
Source

    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxaccordion.js"></script>
    <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxaccordion_dhx_skyblue.css">
    <script src="../../codebase/dhtmlxcontainer.js"></script>

    <div id="accordObj" style="position: relative; width: 320px; height: 400px;"></div>
    <div style="margin: 50px 0px 20px 0px;">
    Select Item <select id="sel"></select> <input type="button" value="Show" onclick="show();"> <input type="button" value="Hide" onclick="hide();">
    </div>
    <script>var sel = document.getElementById("sel");
    var dhxAccord;
    function doOnLoad() {
        dhxAccord = new dhtmlXAccordion("accordObj");
        dhxAccord.addItem("a1", "a");
        dhxAccord.addItem("a2", "b");
        dhxAccord.addItem("a3", "c");
        dhxAccord.openItem("a1");
        dhxAccord.forEachItem(function(item) {
            sel.options.add(new Option(item.getText(), item.getId()));
        });
    }
    function getId() {
        var id = sel.options[sel.selectedIndex].value;
        return id;
    }
    function show() {
        dhxAccord.cells(getId()).show();
    }
    function hide() {
        dhxAccord.cells(getId()).hide();
    }</script>