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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:attribute for javascript

Status
Not open for further replies.

YYYYUU

Programmer
Dec 13, 2002
47
GB
I want to create an attribute for an input box as follows

<xsl:attribute name="onBlur">JAVASCRIPT:checkFieldValidation({@id}, {$minlen})</xsl:attribute>

This javascript works if I just have an input box, but for various reasons I need to split the element down into attributes. Can anyone help me with the syntax for my xsl attribute "onBlur".

Many thanks.
 
Instead of {@id}, {$minlen}... you are going to need to use xsl:value-of tags. {} are away of pulling data out of XML document without including illegal XML characters. How this works:

Code:
<a href="{@id}">Help</a>

This prints out the attribute id as an attribute value for href. Because the following would not work and would cause errors:

Code:
<a href="<xsl:value-of select="@id"/>"/>Help</a>

This is the reasoning behind the {}, when you want to output a value from an XML document into an attribute.

But when the output is not into an attribute, you need to use the xsl:value-of

Code:
<xsl:attribute name="onBlur">JAVASCRIPT:checkFieldValidation(<xsl:value-of select="@id"/>, <xsl:value-of select="minlen"/>)</xsl:attribute>

Hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top