crw150
Technical User
- May 27, 2005
- 20
togShow controls individual buttons. expandCollapse controls all buttons. But the two functions do not work correctly together. What have I done wrong? The button to expandCollapse all must be clicked 2 or 3 times before it works. And once the "all" button has been clicked to hide all, the individual buttons will not work. Also, in the collapseExpand function, how do I toggle the text of the individual buttons? I'm sorry this code is so long, and I hope this makes sense.
crw150
crw150
Code:
var ids = new Array();
function togShow(folderID,obj) {
notedivs = document.getElementById('folder'+folderID);
if(notedivs.style.display=="block" || notedivs.style.display=="")
{
notedivs.style.display="none";
obj.value="click to display";
}
else{
notedivs.style.display="block";
obj.value="click to hide";
}}
function collapseExpand(){
collectElems = document.getElementsByTagName('div');
for(i=0;i<collectElems.length;i++)
if(collectElems[i].className=="answer")
ids[ids.length]=collectElems[i];
for(i=0;i<ids.length;i++)
if(ids[i].style.display=="block" || ids[i].style.display=="")
{ids[i].style.display = "none";
document.f3.b3.value="CLICK TO DISPLAY ALL NOTES";
}
else{
ids[i].style.display = "block";
document.f3.b3.value="CLICK TO HIDE ALL NOTES";
}}
Code:
<div id="toggleallid{generate-id(.)}" class="show">
<form name="f3">
<input name="b3" onclick="javascript:collapseExpand()" type="button" value="CLICK TO HIDE ALL NOTES"/>
</form>
</div>
<div class="container">
<div id="toggleid{generate-id(.)}" class="question">
<form name="f1">
<input name="b1" onclick="javascript:togShow('id{generate-id(.)}',this)" type="button" value="click to hide"/>
</form>
</div>
<div id="answerid{generate-id(.)}" class="answer">
<div id="folderid{generate-id(.)}">
<xsl:apply-templates select="note"/>
</div>
</div>
</div>