gverner
01-25-2004, 07:36 AM
The hardest part about this programming for me is the logic. I am making a menu that uses a + or - sign to show if the menu can expand or collapse.
Everything works until you try to open both at the same time then my + and - get out of sync. What is the best logic to use?
I made a variable named click to catch if the status of the button had been clicked before or not. Thanks for any help.
See below...
<script>
var click=true;
function exp(strTag,strDiv){
var elem = document.getElementById(strTag);
elem.style.display=='none'? elem.style.display='block':elem.style.display='none';
if(click == false){
click=true;
document.getElementById(strDiv).innerHTML ="<CENTER><font face=verdana color=ffffff>(+)</CENTER>";
}else{
click=false;
document.getElementById(strDiv).innerHTML ="<CENTER><font face=verdana color=ffffff>(-)</CENTER>";
}
}
</script>
In the page...
<tr bgcolor=#ffcc66 onclick="exp('table1','table1_div');">
<div ALIGN="left" id=table1_div style="diplay:inline;">
<CENTER>
<font face=verdana color=ffffff>(+)</font>
</CENTER>
</div>
Everything works until you try to open both at the same time then my + and - get out of sync. What is the best logic to use?
I made a variable named click to catch if the status of the button had been clicked before or not. Thanks for any help.
See below...
<script>
var click=true;
function exp(strTag,strDiv){
var elem = document.getElementById(strTag);
elem.style.display=='none'? elem.style.display='block':elem.style.display='none';
if(click == false){
click=true;
document.getElementById(strDiv).innerHTML ="<CENTER><font face=verdana color=ffffff>(+)</CENTER>";
}else{
click=false;
document.getElementById(strDiv).innerHTML ="<CENTER><font face=verdana color=ffffff>(-)</CENTER>";
}
}
</script>
In the page...
<tr bgcolor=#ffcc66 onclick="exp('table1','table1_div');">
<div ALIGN="left" id=table1_div style="diplay:inline;">
<CENTER>
<font face=verdana color=ffffff>(+)</font>
</CENTER>
</div>