Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Location
    melbourne, aus
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic tree, selected node sets form value

    hello all

    i'm after something similar to the yahoo dynamic tree

    http://developer.yahoo.com/yui/exam....html?mode=dist

    where i can have the selected leaf/node set a hidden value in a form
    i don't think the yahoo one knows what is selected
    also, similar to http://www.blueshoes.org/_bsJavascr...s/example8.html
    but without the links, just purely selecting the node (not the radio button), and also free/open source

    each node should have an id associated with it (this is selected from the database along with the text for the node (which i have already succeeded in doing, albeit very roughly))

    eg. base node (id 1)
    -- first child node (id 2)
    -- second child node (id 3)
    ---- grandchild node (id 4)
    -- third child node (id 5)
    ---- grandchild node (id 6)
    ------ great grandchild node (id 7)
    ---- grandchild node (id 8)

    where for example, when "third child node" is selected, a hidden field will have its value set to "5", etc.

    does anyone know of a ready-made script for this?
    or a script that can be easily modified to do this?

    i am not great at javascript, but can usually hack up some code (not too much) to make it do what i want

    thanks
    dave

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    hrmmmm... not sure if this is what you are talking about what its worth a shot.....


    put an onclick method on each node:

    onclick="somefunction(this.id);"

    then in the function do as so:


    functio somefunction(val){
    //if your hidden input has an id do as so
    document.getElementById('hiddeninputid').value=val;
    //if the hidden input is in a form without an id but has a name do as so
    document.formname.hiddeninputname.value=val;

    }
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •