DHTMLX Docs & Samples Explorer

### Accessing Items

Select Item
New Text
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> New Text <input id="newText" type="text" value="New Text"> <input type="button" value="Set Text" onclick="setText();">
    </div>
    <script>var dhxAccord;
    var sel = document.getElementById("sel");
    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 setText() {
        dhxAccord.cells(getId()).setText(document.getElementById("newText").value);
    }</script>