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 Coder
    Join Date
    Jan 2005
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    javascript tree toggle

    I'm putting together a javascript folder tree but I do not want more than one node expanded at a time. Below is the working function I've put together but I have no idea how to code it to close previous nodes when opening a new one. Any advice would be appreciated! Thanks

    var _image_dir = new Image();_image_dir.src="img/fe.gif";
    var _image_diropen = new Image();_image_dir.src="img/fc.gif";
    var _image_item = new Image();_image_dir.src="img/d.gif";
    function setExpandedIco(id){var i=document.getElementById(id+'_image');i.src='img/fe.gif';}
    function setCollapsedIco(id){var i=document.getElementById(id+'_image');i.src='img/fc.gif';}
    function toggleNode(id){if(toggleLayer(id+'_subitems'))setExpandedIco(id);else setCollapsedIco(id);}
    function toggleLayer(id){var l=document.getElementById(id);var s=l.style||l;if(s.visibility=='hidden'){s.visibility='visible';s.display='block';return true;}else{s.visibility='hidden';s.display='none';return false;}}

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Welcome to the Coding Forums

    You posted this in the wrong place, if you would read this: *** WARNING: Questions posted here will be deleted! ***

    Eric
    Last edited by brothercake; 01-12-2005 at 01:27 PM.
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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