Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-10-2006, 02:38 AM   PM User | #1
SlicedBread
New to the CF scene

 
Join Date: Apr 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
SlicedBread is an unknown quantity at this point
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>
SlicedBread is offline   Reply With Quote
Old 05-10-2006, 03:54 AM   PM User | #2
CrAzY_J
Regular Coder

 
Join Date: May 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
CrAzY_J is an unknown quantity at this point
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);
}
CrAzY_J is offline   Reply With Quote
Old 05-11-2006, 03:09 AM   PM User | #3
SlicedBread
New to the CF scene

 
Join Date: Apr 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
SlicedBread is an unknown quantity at this point
Smile Thank you, Thank you, Thank you!!

thank you so much it worked like a charm!!!
SlicedBread is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:01 AM.


Advertisement
Log in to turn off these ads.