By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,450 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,450 IT Pros & Developers. It's quick & easy.

Dtree node value when selected

P: 6
I'm new to javascript and i need to solve a simple problem: i need to catch the value of a node of dtree when selected, but i don't know how can i get it (doesn't matter what value ... node id, node name, url, ect. are all good for my purpose). I've tried it in many ways, but it really seems there no way to get it! for example, since the url appears in the status bar, i've written the following line: <body onMouseDown=alert(window.status);> but the result is always the same: an empty message! thank you for your help

p.s. sorry for my bad english
Feb 21 '12 #1
Share this Question
Share on Google+
6 Replies


Dormilich
Expert Mod 5K+
P: 8,639
found at MDC
Sets the text in the status bar at the bottom of the browser or returns the previously set text.
since you can't set text, there is no return value. besides that, the status bar is increasingly unimportant, if enabled at all.


what is a dtree?
Feb 21 '12 #2

P: 6
dtree is a very popular tree written in javascript that you can find at the following address:

http://destroydrop.com/javascripts/tree/

it's easy to use ... but i'm not able to use it in a dynamic mode ... for example, I'd like to add a new node to the tree on the fly, but since I'm not able to detect the id or the name or the url of the selected node, i can do nothing!!
(the url appears in the status bar, when you move the mouse over the node)
do you have an idea?
thank you very much for your answer
Feb 22 '12 #3

Dormilich
Expert Mod 5K+
P: 8,639
there is a general problem. when you look at the API, you'll find the following:
add()

Adds a node to the tree.
Can only be called before the tree is drawn.
in other words, there is no possibility to modify the tree after its creation (which is what you want to do)
Feb 22 '12 #4

P: 6
i know ... but i use a trick ... i add a button at the end of the tree, i click on the button and i open a new page, in this page there are some scripts, i mean some routines ... well, i write some parameters into an input field, then i click submit, and the new node is added to the tree, by saving all into a .htm file (using activex method), then i reload the page ... the problem is, since i'm not able to detect any information about the selected node, since i don't know where to add the new node, i have to set the parameters (node id and parent id) manually, using an input field ... it isn't an elegant way!! at least three steps are required! ... dtree is really very easy to use, you can simply append a node at the end of the file, but if you want that the node appears after node C and not after node E, you need to know the id of node C ... for example, node C id is 2 and the new node is added after a list of 20 nodes, so you simply write "add(20,2,'name','link')" ...
Feb 23 '12 #5

P: 6
solved!!

this is the code to build the tree ...

Expand|Select|Wrap|Line Numbers
  1. d = new dTree('d');
  2. d.config.target = 'RightSide';
  3.  
  4. d.add(0,-1,'My example tree');
  5. d.add(1,0,'Node 1','Panel.html');
  6. d.add(2,0,'Node 2','#');
  7. ect. ect.
than i've used this function:

Expand|Select|Wrap|Line Numbers
  1. function showFramePage() {
  2.         var pageAddress = parent.RightSide.location.href.split("/") 
  3.         pageAddress = pageAddress [pageAddress.length-1]
  4.         alert(pageAddress);
  5.         }
and a button:

Expand|Select|Wrap|Line Numbers
  1. <input type="button" name="showpage" value="Show page" onclick="showFramePage();">
Mar 13 '12 #6

P: 1
Hi,
Seems like you are using frames with dtree, which I also use.
But not my target is a div in the same page.
Can you explain how to target in the same page?

I tried:
d.add(id, pid, "Some Name", "javascript:jsfunc(arg)");

jsfunc(arg) {
document.getElementById("someId").src = arg.src;
(where "arg" is the path to an image file).
This opens a new browser window and displays the picture.
Mar 5 '14 #7

Post your reply

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