Location: PHPKode > projects > Neobill > NeoBill0.5.6/include/dhtmlxTree/samples/treeEx12.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<title>DHTML Tree samples. dhtmlXTree - Add / Delete items</title>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script type="text/javascript" src="../js/dhtmlXCommon.js"></script>
	<script type="text/javascript" src="../js/dhtmlXTree.js"></script>
	<script type="text/javascript">
		function fixImage(id){
			switch(tree.getLevel(id)){
			case 1:
			tree.setItemImage2(id,'books_close.gif','tombs.gif','tombs.gif');
				break;
			case 2:
			tree.setItemImage2(id,'book.gif','books_open.gif','books_close.gif');
				break;
			case 3:
			tree.setItemImage2(id,'book.gif','books_open.gif','book.gif');
				break;
			default:
			tree.setItemImage2(id,'book_titel.gif','book_titel.gif','book_titel.gif');
				break;
			}
		}
	</script>
	<style type="text/css">
	body { font-family:arial;font-size:12px; font-size:12px; }
	h1 {cursor:pointer;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0;font-family:courier;background-color:#e6e6fa;padding:2px}
	</style>
</head>
<body>
	<h1>Add / Delete items</h1>
	<table>
		<tr>
			<td valign="top">

				<div id="treeboxbox_tree" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
			</td>
			<td rowspan="2" style="padding-left:25px" valign="top">
			
			<a href="javascript:void(0);" onclick="var d=new Date(); tree.insertNewItem(tree.getSelectedItemId(),d.valueOf(),document.getElementById('ed1').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new child item</a> Item label <input type="text" value="New item" id="ed1"><br><br>
			
			<a href="javascript:void(0);" onclick="var d=new Date(); tree.insertNewNext(tree.getSelectedItemId(),d.valueOf(),document.getElementById('ed2').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new item next</a> Item label <input type="text" value="New item" id="ed2"><br><br>
			
			<a href="javascript:void(0);" onclick="tree.deleteItem(tree.getSelectedItemId(),true);">Delete item</a><br><br>
				
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
	<hr>
			
<XMP>
<div id="treeboxbox_tree" style="width:200px;height:200px"></div>
<script type="text/javascript">
	tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.setImagePath("../imgs/");
		tree.loadXML("tree.xml")
		
		tree.insertNewItem(0,100,"New Node 1",0,0,0,0,"SELECT");
		tree.insertNewNext(2,101,"New Node 2",0,0,0,0,"");
		tree.deleteItem("2");
</script>
</XMP>	
		<li>0s passed to the function for arguments 4-7 (function to call on select, images) mean use default values for them</li>
		<li>Last argument is a comma delimited string of following possible value (upper case only):</li>
			<li type="circle">SELECT - move selection to this node after inserting</li>
			<li type="circle">CALL - call function on select</li>
			<li type="circle">TOP - add node to the top position </li>
			<li type="circle">CHILD - node has children</li>
			<li type="circle">CHECKED - checkbox is checked (if exists)</li>
	<script type="text/javascript">
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.loadXML("tree3.xml");
/*		
			tree.insertNewItem(1,100,"New Node 1",0,0,0,0,"SELECT");
			tree.insertNewNext(2,101,"New Node 2",0,0,0,0,"");
			tree.deleteItem("2");*/
	</script>
<br><br>

</body>
</html>
Return current item: Neobill