how to remove select boxes at once

Discussion in 'JavaScript' started by jj0914, Aug 17, 2007.

  1. #1
    I have 5 dependent select boxes, if I want to remove all low-level select boxes when selection of first box is changed, How can I do that? Thanks
     
    jj0914, Aug 17, 2007 IP
  2. Deathmaster

    Deathmaster Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    something like this?
    
    <html>
    <head>	
    <script type="text/javascript">
    function toggle(div){
    		var d = document.getElementById(div).style.display;
    		if(d=="") {
    			document.getElementById(div).style.display = "none";  
    		} else {
    			document.getElementById(div).style.display = "";
    		}
    
    }
    </script>
    </head>
    <body>
    <form>
    toggle <input type="checkbox" id="toggler" onclick="toggle('boxes')" />
    <div id="boxes">low-level 1<input type="checkbox"  />
    <br />low-level 2<input type="checkbox"  />
    <br />low-level 3<input type="checkbox"  />
    <br />low-level 4<input type="checkbox"  />
    <br />low-level 5<input type="checkbox"  /></div>
    </form>
    </body>
    </html>
    Code (markup):
     
    Deathmaster, Aug 17, 2007 IP
  3. jj0914

    jj0914 Guest

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply.
    I tried your code, it works quit different than what I am expecting.
    the 5 select boxes I have are dependent, e.g if I choose the item in first box doesn't have children, then all the low-level select boxes from previous selection will be gone, if I select the item in second box doesn't have children, all his low-level select box will be gone, etc.

    Thanks again for the help
     
    jj0914, Aug 17, 2007 IP