We help IT Professionals succeed at work.
Get Started

Javascript onclick to set visibility in XSLT

jmc430
jmc430 asked
on
686 Views
Last Modified: 2010-08-05
Greetings,

I'm attempting to create some functionality for a collapsible navigation bar using Javascript and XSLT.  Basically, I want all the child nodes of a parent to be set to invisible until the parent node is clicked.  

Currently my output appears like this:

Title 1
   Subtitle 1.1
   Subtitle 1.2

Title 2
   Subtitle 2.1
   Subtitle 2.2

I would like my output to appear like this:

Title 1
Title 2

and only have the Subtitles visible only when the Title hyperlink is clicked.

Here is the XSLT:

<xsl:for-each select="child::NEWSTYPE/TITLE">
<a>
<xsl:attribute name="HREF">
<xsl:text disable-output-escaping="yes">#</xsl:text>
<xsl:value-of select="../@ID"/>
</xsl:attribute>
<xsl:value-of select="."/>
</a><br/>

<xsl:for-each select="following-sibling::NEWSAREA/TITLE">
<a>
<xsl:attribute name="HREF">
<xsl:text disable-output-escaping="yes">#</xsl:text>
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</a><br/>
</xsl:for-each>
<br/>
</xsl:for-each>

I have been making several attempts of tweaking the <A attribute onclick="return false" STYLE="visibility:hidden"> ... to no avail.  I've embedded some javascript to the parent document and don't know how to fix this ...

Any advice or guidance is greatly appreciated!

Thanks so much for helping me!
Jamie
Comment
Watch Question
Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE