...

View Full Version : another hide/show div problem



SlicedBread
05-10-2006, 03:38 AM
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>

CrAzY_J
05-10-2006, 04:54 AM
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);
}

SlicedBread
05-11-2006, 04:09 AM
thank you so much it worked like a charm!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum