...

View Full Version : Dynamic tree, selected node sets form value



dtra
11-13-2006, 02:41 AM
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

brandonH
11-14-2006, 08:53 AM
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;

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum