crw150
Technical User
- May 27, 2005
- 20
Hi,
I'm an extreme newbie to JavaScript, have searched dozens of threads and examples, but I'm still not sure what I should be trying to do. My XML document contains <item> elements, and some <item> elements contain a <note> element. I managed to write a JavaScript code that lets the user "display" or "hide" each note. But now I need a "[Display All | Hide All]" option at the top of the document. The pertinent parts of my stylesheet are pasted in below. What is the simplest way for me to add the expand/collapse all option? I'm sure this is quite basic, but if anyone is willing to take a look at this, I'd welcome any help or suggestions for what keywords to search.
Thanks,
crw150
<xsl:template match="/">
...
function unfold(folderID) {
anchor = document.getElementById('anchor'+folderID);
folder = document.getElementById('folder'+folderID);
// hide expand icon
// show folder div
anchor.style.display = "none";
folder.style.display = "block";
return;
}
function fold(folderID, display) {
anchor = document.getElementById('anchor'+folderID);
folder = document.getElementById('folder'+folderID);
// show expand icon
// hide folder div
anchor.style.display = display;
folder.style.display = "none";
return;
}
...
<table>
...
<xsl:for-each select="item">
...
<xsl:if test="note">
<span style="display:block;" id="anchorid{generate-id(.)}">
<a href="javascript:unfold('id{generate-id(.)}')" class="collapsed">+ Notes: (click to display)</a>
</span>
<div id="folderid{generate-id(.)}" class="folding">
<h5 class="folderlink">
<a href="javascript:fold('id{generate-id(.)}', 'block')" class="expanded">- Notes: (click to hide)</a>
</h5>
<div class="fixed">
<xsl:apply-templates select="note"/>
</div>
</div>
</xsl:if>
...
</xsl:template>
I'm an extreme newbie to JavaScript, have searched dozens of threads and examples, but I'm still not sure what I should be trying to do. My XML document contains <item> elements, and some <item> elements contain a <note> element. I managed to write a JavaScript code that lets the user "display" or "hide" each note. But now I need a "[Display All | Hide All]" option at the top of the document. The pertinent parts of my stylesheet are pasted in below. What is the simplest way for me to add the expand/collapse all option? I'm sure this is quite basic, but if anyone is willing to take a look at this, I'd welcome any help or suggestions for what keywords to search.
Thanks,
crw150
<xsl:template match="/">
...
function unfold(folderID) {
anchor = document.getElementById('anchor'+folderID);
folder = document.getElementById('folder'+folderID);
// hide expand icon
// show folder div
anchor.style.display = "none";
folder.style.display = "block";
return;
}
function fold(folderID, display) {
anchor = document.getElementById('anchor'+folderID);
folder = document.getElementById('folder'+folderID);
// show expand icon
// hide folder div
anchor.style.display = display;
folder.style.display = "none";
return;
}
...
<table>
...
<xsl:for-each select="item">
...
<xsl:if test="note">
<span style="display:block;" id="anchorid{generate-id(.)}">
<a href="javascript:unfold('id{generate-id(.)}')" class="collapsed">+ Notes: (click to display)</a>
</span>
<div id="folderid{generate-id(.)}" class="folding">
<h5 class="folderlink">
<a href="javascript:fold('id{generate-id(.)}', 'block')" class="expanded">- Notes: (click to hide)</a>
</h5>
<div class="fixed">
<xsl:apply-templates select="note"/>
</div>
</div>
</xsl:if>
...
</xsl:template>