
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 2.02 KB | hits: 11 | expires: Never
XSLT: Output Javascript in the element tag
<div onclick="var e = document.getElementById('<xsl:value-of select="div_id"/>');
if(e.style.display == 'block')
e.style.display = 'none';
else
{
e.style.display = 'block';
e.scrollIntoView();
}"
style="text-decoration: underline; color: blue;"
>Toggle</div>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<div style="text-decoration: underline; color: blue;"
onclick="var e = document.getElementById('{div_id}');
if(e.style.display == 'block')
e.style.display = 'none';
else
{{
e.style.display = 'block';
e.scrollIntoView();
}}">Toggle</div>
</xsl:template>
</xsl:stylesheet>
<div_id>3</div_id>
<div style="text-decoration: underline; color: blue;" onclick="var e = document.getElementById('3'); if(e.style.display == 'block') e.style.display = 'none'; else { e.style.display = 'block'; e.scrollIntoView(); }">Toggle</div>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<div style="text-decoration: underline; color: blue;">
<xsl:attribute name="onclick">
var e = document.getElementById('<xsl:value-of select="div_id"/>');
if(e.style.display == 'block')
e.style.display = 'none';
else
{
e.style.display = 'block';
e.scrollIntoView();
}</xsl:attribute>Toggle</div>
</xsl:template>
</xsl:stylesheet>
<div onclick="var e = document.getElementById('{div_id}'); ...">Toggle</div>