<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="sel">
<option value="history">History</option>
<option value="page_setup">Page</option>
<option value="print">Print</option>
</select>
<input type="button" value="Get Text" onclick="getText();">
<input type="button" value="Set Text" onclick="setText();">
<input id="txt" type="text" value="New Text">
</div>
<script>var sel = document.getElementById("sel");
var toolbar = new dhtmlXToolbarObject("toolbarObj");
toolbar.setIconsPath("../common/imgs/");
toolbar.loadXML("../common/dhxtoolbar_buttonselect.xml?etc=" + new Date().getTime(), updateList);
function getId() {
var id = sel.options[sel.selectedIndex].value;
return id;
}
function setText(text) {
toolbar.setItemText(getId(), document.getElementById("txt").value);
}
function getText() {
var text = toolbar.getItemText(getId());
if (text == "")
text = "This item has no text";
alert(text);
}
function updateList() {
sel.options.length = 0;
toolbar.forEachItem(function(itemId) {
if (toolbar.getType(itemId) == "buttonSelect") {
sel.options.add(new Option(itemId, itemId));
}
});
}
</script>