Dtree node value when selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • francom
    New Member
    • Feb 2012
    • 6

    Dtree node value when selected

    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=ale rt(window.statu s);> but the result is always the same: an empty message! thank you for your help

    p.s. sorry for my bad english
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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?

    Comment

    • francom
      New Member
      • Feb 2012
      • 6

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



      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

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        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)

        Comment

        • francom
          New Member
          • Feb 2012
          • 6

          #5
          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')" ...

          Comment

          • francom
            New Member
            • Feb 2012
            • 6

            #6
            solved!!

            this is the code to build the tree ...

            Code:
            d = new dTree('d');
            d.config.target = 'RightSide';
            
            d.add(0,-1,'My example tree');
            d.add(1,0,'Node 1','Panel.html');
            d.add(2,0,'Node 2','#');
            ect. ect.
            than i've used this function:

            Code:
            function showFramePage() {
            		var pageAddress = parent.RightSide.location.href.split("/") 
            		pageAddress = pageAddress [pageAddress.length-1]
            		alert(pageAddress);
            		}
            and a button:

            Code:
            <input type="button" name="showpage" value="Show page" onclick="showFramePage();">
            Last edited by Dormilich; Mar 13 '12, 09:38 PM. Reason: Please use [CODE] [/CODE] tags when posting code.

            Comment

            • jc0966
              New Member
              • Mar 2014
              • 1

              #7
              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:jsf unc(arg)");

              jsfunc(arg) {
              document.getEle mentById("someI d").src = arg.src;
              (where "arg" is the path to an image file).
              This opens a new browser window and displays the picture.

              Comment

              Working...