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 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing display to none with javascript and onclick

    I have three subsections of my menu -- places of interest, boarding and comparisons. When clicked, each will reveal a UL with a set of links. When I click on each of the three titles, I want any of the other two to change their display to none. Can someone give me a starting point to go on? Here is the webpage.


    Thanks
    Last edited by amory_tarr; 08-27-2004 at 03:22 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Code:
    function hideULs(exceptId, containerId){
       var obj = (containerId) ? document.getElementById(containerId):document;
       if (obj && obj.getElementsByTagName){
          uls = obj.getElementsByTagName("UL");
          for (var i=0;i<uls.length;i++){
             if (uls[i].id!=exceptId){
                uls[i].style.display="none";
             }
          }
       }
    }
    
    function WM_toggle(id){
       var obj = document.getElementById(id);
       obj.style.display = (obj.style.display == "none") ? "block":"none";
       if (obj.style.display=="block") hideULs(id, "layout-mainright");
       return false;
    } 
    ...
    <div id="layout-mainright">
    <br />
    
    <h4><a href="#" onclick="return WM_toggle('navigation');">Places of interest</a></h4>
    ...


  •  

    Posting Permissions

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