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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to hide all drop down boxes on a page?

    I've made a drop down menu that shows/hides different layers. But sometimes there's a drop down box where the menu should appear and then drop down box is placed above the layer.

    Now I'm looking for a script that hides all drop down boxes on the page. The problem is I have a lot of pages in my site and different pages have different amount of drop down boxes.

    How can I make a script that automatically hides all drop down boxes?

    Regards
    Gustaf

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function hideAllSelects() {
         var collS = document.getElementsByTagName("SELECT");
         for (var i=0; i<collS.length; i++)
              collS[i].style.visibility = 'hidden';
         }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks very much!

    However, the select-boxes are inside an iframe and I can't seem to refer to it the right way.

    This is how the script looks now: (the IFRAME is named and ID'd "main")


    function hideAllSelects() {
    target = document.getElementById("main");
    var collS = target.getElementsByTagName("SELECT");
    for (var i=0; i<collS.length; i++)



    if (collS[i].style.visibility == 'hidden')
    {
    collS[i].style.visibility = "";
    } else
    {
    collS[i].style.visibility = 'hidden';
    }

    }


  •  

    Posting Permissions

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