473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Save the tree structure of nodes in HTML??

I display a tree of nodes in a page of html. and use javascript to enable the page users to move nodes around. But I dont know how I can save the change of the tree structure? Is it possible at all to get the position of nodes from javascript?
Oct 16 '07 #1
10 2911
gits
5,390 Expert Mod 4TB
hi ...

:) ... tricky problem ... you should find a database-representation for that structure and you have to save that for the specific user ... its like a user-specific page-config ... may be you could save the current innerHTML of the document and set it back later on when the user comes back?

kind regards
Oct 17 '07 #2
gits
5,390 Expert Mod 4TB
merged threads ... please don't double post your questions ...

kind regards

ps: don't even triple- or multipost your questions, i've deleted your third one regarding this problem!
Oct 17 '07 #3
Thanks a lot for the reply!

Actually the information of the nodes in this html is read from a Matlab data source. I read them from Matlab and display them using a browser driven by Matlab - I will need to run Matlab commands in this brower, the commands dont work in other browser. I'd like to change the positions of the nodes and save the structure back to the Matlab data source.

But I checked all the commands available for html and javascript, seems them can only get information from fixed source code of html, unless using PHP - which is a little bit too far for this Matlab browser.

Cheers,
JoJo

hi ...

:) ... tricky problem ... you should find a database-representation for that structure and you have to save that for the specific user ... its like a user-specific page-config ... may be you could save the current innerHTML of the document and set it back later on when the user comes back?

kind regards
Oct 18 '07 #4
Anybody has a clue for this problem?? I have been searching for a solution for so long. Seems that I cannot finish my project the way I expect.
Oct 23 '07 #5
Up one more time. Anybody can help me??!! Thanks.
Oct 26 '07 #6
acoder
16,027 Expert Mod 8TB
Can you show your code so far.
Oct 29 '07 #7
An example of the source code is as following. In the example, I have four nodes (except the root node). The "average" node has a child "divide". The "divide" node has two children "sum" and "FFT". The purpose of using JSript to move the nodes around is for the user to to change the structure of the tree so that the tree can better represent the user's understanding for a biomedical problem.

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script type="text/javascript" src="../../../../Program%20Files/MUnit/MUnit/js/ajax.js"></script>
<script type="text/javascript" src="../../../../Program%20Files/MUnit/MUnit/js/context-menu.js"></script><!-- IMPORTANT! INCLUDE THE context-menu.js FILE BEFORE drag-drop-folder-tree.js -->
<script type="text/javascript" src="../../../../Program%20Files/MUnit/MUnit/js/drag-drop-folder-tree.js">
</script>
<link rel="stylesheet" href="../../../../Program%20Files/MUnit/MUnit/munit.css" type="text/css"/>
<title>MUnit Control Panel</title>
</head>
<body>
<div id=banner>
<!-- It is part of the license agreement that this banner
remains intact and displayed in reports -->
MUnit from <a href="http://xtargets.com">XTargets</a><br/>
Copyright Brad Phelan 2005, under the GPL license.
</div>
<div id=contents>
<h1>MUnit Control Panel </h1>
<h2>Add Test Suites</h2>
<div id="add">
Enter the name of a test case file eg: <i>my_testcase</i>. If the
file exists it will be added to the control panel. If it doesn't
exist you will be asked to choose a directory and a new template
test will be created.
<form method="post" action="matlab:munit_cgi">
<input name="test" value="">
<input type="hidden" name="dispatch" value="add"/>
<input type="submit" name="add" value="add"/>
</form>
</div>
<h2>Test Suites</h2>
<div id="tests">
<ul id="dhtmlgoodies_tree2" class="dhtmlgoodies_tree">
<p id="node0" noDrag="true" noSiblings="true" noDelete="true" noRename="true">
<a href="#">Root node</a> </p>
<ul>
<li id="node1"><a href="#">average
<a href="matlab:edit('test_average');">edit</a>
<a href="matlab:munit_control_panel('suite','test_ave rage');">run</a>
<a href="matlab:munit_control_panel('del','test_avera ge');">remove</a>
<br/>
<ul>
<li id="node2"><a href="#">divide
<a href="matlab:edit('test_divide');">edit</a>
<a href="matlab:munit_control_panel('suite','test_div ide');">run</a>
<a href="matlab:munit_control_panel('del','test_divid e');">remove</a>
<br/>
<ul>
<li id="node3"><a href="#">sum
<a href="matlab:edit('test_sum');">edit</a>
<a href="matlab:munit_control_panel('suite','test_sum ');">run</a>
<a href="matlab:munit_control_panel('del','test_sum') ;">remove</a>
<br/>
<li id="node4"><a href="#">FFT
<a href="matlab:edit('test_FFT');">edit</a>
<a href="matlab:munit_control_panel('suite','test_FFT ');">run</a>
<a href="matlab:munit_control_panel('del','test_FFT') ;">remove</a>
<br/>
</ul>
</a>
</li>
</ul>
</a>
</li>
</ul>
</ul>
</div>
</div>
<script type="text/javascript">
treeObj = new JSDragDropTree();
treeObj.setTreeId('dhtmlgoodies_tree2');
treeObj.setMaximumDepth(3);
treeObj.setMessageMaximumDepthReached('Maximum depth reached'); // If you want to show a message when maximum depth is reached, i.e. on drop.
treeObj.initTree();
treeObj.expandAll();
</script>
<a href="#" onclick="treeObj.collapseAll()">Collapse all</a> |
<a href="#" onclick="treeObj.expandAll()">Expand all</a>
</body>
</html>[/HTML]

My problem is that, the structure of nodes is read from a matlab file, means it is not stored on a server so that I can send back the nodes' information by ajax. The only way I can think of is to get the relationship of nodes by JScript. But I dont know whethere it is possilbe at all to do that?? Please leave ur comment if you have any idea on this. Thank you very much!
Nov 4 '07 #8
acoder
16,027 Expert Mod 8TB
You could save this information using cookies. You only need to store the positions of the nodes, i.e. left and top values.
Nov 5 '07 #9
You could save this information using cookies. You only need to store the positions of the nodes, i.e. left and top values.
Thanks for replying. I have never used cookies before so my understanding might be wrong. But according to my knowledge, cookies are used to store information between a server and a client in http. In my case, matlab and the browser are not the same as a server and a client?
Nov 6 '07 #10
acoder
16,027 Expert Mod 8TB
Thanks for replying. I have never used cookies before so my understanding might be wrong. But according to my knowledge, cookies are used to store information between a server and a client in http. In my case, matlab and the browser are not the same as a server and a client?
You can have client-side cookies. Read this article (contains useful cookie functions) and this tutorial.
Nov 6 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jeffrey Silverman | last post by:
Hi, all. I have a linked list. I need an algorithm to create a tree structure from that list. Basically, I want to turn this: $list = array( array( 'id' => 'A', 'parent_id' => null, 'value'...
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
1
by: Robin Tucker | last post by:
Ouch. I've got a nasty problem here. I need to load a tree structure into a treeview from a database. I've just tested it with 10,000 items and its dog slow (one of the main reasons is because...
3
by: _DS | last post by:
Problem with mapping a directory tree to a tree control: It takes a while to recurse subdirs and map them to nodes. This is solved in some books I've seen (MacDonald, Albahari) by reading the...
1
by: David Hirschfield | last post by:
I've written a tree-like data structure that stores arbitrary python objects. The objective was for the tree structure to allow any number of children per node, and any number of root nodes...and...
3
by: Alex | last post by:
What does it mean to "walk the DOM tree"? How do you use it? I hear programmers using this term loosely and I'm not sure what it means. I understand that DOM means Document Object Module and that...
22
by: delraydog | last post by:
It's quite simple to walk to the DOM tree going forward however I can't figure out a nice clean way to walk the DOM tree in reverse. Checking previousSibling is not sufficient as the...
5
by: hankypan1 | last post by:
Hi All, I need a tree data structure for my application. It is the non -cyclic simple tree where i can have any number of children node and each child can recursively become a sub tree like a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.