DHTMLX Docs & Samples Explorer

Button Select Listed Option Tooltip

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: 200px;">
<select id="sel2"></select>
<input type="button" value="Get Tooltip" onclick="getTip();">
<input type="button" value="Set Tooltip" onclick="setTip();">
<input id="txt" type="text" value="New Tooltip">
</div>
<script>
var sel2 = document.getElementById("sel2");
var toolbar = new dhtmlXToolbarObject("toolbarObj");
toolbar.setIconsPath("../common/imgs/");
toolbar.loadXML("../common/dhxtoolbar_buttonselect.xml?etc=" + new Date().getTime(), updateList);
function getId() {
    var id = (sel2.options[sel2.selectedIndex].value).split(";");
    return id;
}
function setTip(text) {
    var id = getId();
    toolbar.setListOptionToolTip(id[0], id[1], document.getElementById("txt").value);
}
function getTip() {
    var id = getId();
    var tip = toolbar.getListOptionToolTip(id[0], id[1]);
    if (tip == "")
        tip = "This item has no tooltip";
    alert(tip);
}
function updateList() {
    sel2.options.length = 0;
    toolbar.forEachItem(function(itemId) {
        if (toolbar.getType(itemId) == "buttonSelect") {
            toolbar.forEachListOption(itemId, function(listId) {
                if (toolbar.getTypeExt(listId) != "separator") {
                    sel2.options.add(new Option(itemId + " - " + listId, itemId + ";" + listId));
                }
            });
        }
    });
}
</script>