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
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question another hide/show div problem

    I thought I had my problem solved now my manager wants one item to show while the other hides. In a nutshell I have 2 divs that have radio buttons to show them. when one is clicked the other should hide but I've got it all screwed up. Here is the code I'm working with so far.
    Thanks in advance
    Amy
    -------------
    <script type="text/javascript">
    <!-- Begin

    var subs_array = new Array("sub1","sub2");// Put the id's of your hidden divs in this array

    function displaySubs(the_sub){

    if (document.getElementById(the_sub).style.display==""){

    document.getElementById(the_sub).style.display = "none";return

    }

    for (i=0;i<subs_array.length;i++){

    var my_sub = document.getElementById(subs_array[i]);

    my_sub.style.display = "none";

    }

    document.getElementById(the_sub).style.display = "";

    }

    // End -->

    </script>
    ------------------------------
    <TABLE cellSpacing="1" cellPadding="1" bordercolor="#ff00ff" border="0">
    <TR>
    <TD class="Normal" width="160">&nbsp;&nbsp;&nbsp;<input type="Radio" onclick="displaySubs('sub1')">Show Selected Accounts</TD>
    <TD class="Normal" width="130"><input type="Radio" onclick="displaySubs('sub2')">Show All Accounts</TD>
    </TR>
    </TABLE>
    -----------------
    <div id="sub1" style="display:none" class="tag"> blah blah blah</div>
    <div id="sub2" style="display:none" class="tag"> blah blah blah2</div>

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function hide_other(but){
    for(var a=0;a<sub_array.length;a++){
    if(sub_array[a]!=but){
    document.getElementById(sub_array[a]).style.display='none';
    }}}
    
    function displaySubs(the_sub){
    document.getElementById(the_sub).style.display='';
    hide_other(the_sub);
    }

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thank you, Thank you, Thank you!!

    thank you so much it worked like a charm!!!


  •  

    Posting Permissions

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