Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using XSLT to add modify code 1

Status
Not open for further replies.

gacaccia

Technical User
May 15, 2002
258
US
i want to create an html page by parsing a source xml file using xslt. the end product should include a javascript function that takes an element id as a parameter. the javascript function is called by the onclick method of certain <span> elements. for example...

Code:
<span onclick="toggleDisplay('Item1')>+</span><span>Item1</span>
<div id="Item1">content goes here</div>

is there a way to use xslt to change the parameter getting passed into the function "toggleDisplay"? i would like to do something like...

Code:
<span onclick="toggleDisplay('<xsl:value-of select="@name"/>')>

...but that doesn't work. how do i insert text from xslt into the middle of html code that is quoted?

thanks,

glenn
 
><span onclick="toggleDisplay('<xsl:value-of select="@name"/>')>

[1] This is where you can use AVT (attribute value template).
ref (for instance)

[tt]<span onclick="toggleDisplay('[blue]{@name}[/blue]')>[/tt]

[2] To work it out without using avt, it look like this.
[tt]
<span>
<xsl:attribute name="onclick">
<xsl:text>toogleDisplay('</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>')</xsl:text>
</xsl:attribute>
<!-- continue with other text or else -->
</span>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top