DHTMLX Docs & Samples Explorer

Iterator

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;">
<input type="button" value="Set Text" onclick="setText();">
</div>
<script>
var names = new Array("a", "b", "c");
var names2 = new Array("Gothic 3 Forsaken Gods", "NFS Undercover", "Diablo 2 Lord Of Destruction");
var newNames = true;
var j = 0;
var dhxAccord;
function doOnLoad() {
    dhxAccord = new dhtmlXAccordion("accordObj");
    for (var q = 0; q < names2.length; q++)
        dhxAccord.addItem("a" + q, names2[q]);
    dhxAccord.openItem("a0");
}
function setText() {
    dhxAccord.forEachItem(function(item) {
        item.setText(newNames ? names[j++] : names2[j++]);
    });
    newNames = !newNames;
    j = 0;
}
</script>