How to get the same behavior like xsl:value-of select in an onclick hyperlink attribute?
I've got an xsl issue, this is the situation:
<td onclick="location.href='/vakman/default.asp?name='" style="cursor:pointer" valign="top" height="100%">
After default.asp?name='
I need this value: <xsl:value-of select="veld[5]" />
Can someone help me with the right notation?
UPDATE
Here's some more of the code I use:
<table border="0" align="right" cellspacing="4" cellpadding="0">
<xsl:for-each select="//regels/item">
<xsl:variable name="coor" select="veld[1]" />
<xsl:variable name="coor1" select="veld[2]" />
<xsl:variable name="naam" select="veld[5]"/>
<xsl:value-of select="xsl:getKop()" disable-output-escaping="yes" />
开发者_StackOverflow <td onclick="location.href='/vakman/default.asp?naam='" style="cursor:pointer" valign="top" height="100%">
<table border="0" cellspacing="4" cellpadding="0" class="toppersTable" width="250px" height="75px">
<tr><td>
<b>
<xsl:value-of select="xsl:showOms(string(veld[5]))" />
<xsl:value-of select="xsl:showOms(string(veld[6]))" /></b><br />
<xsl:value-of select="xsl:showOms(string(veld[8]))" /><br />
<xsl:value-of select="xsl:showOms(string(veld[9]))" />
<xsl:value-of select="xsl:showOms(string(veld[10]))" /><br />
<xsl:value-of select="xsl:showOms(string(veld[11]))" />
</td></tr>
</table>
</td>
<xsl:value-of select="xsl:getBottom()" disable-output-escaping="yes" />
<xsl:value-of select="$coor" />
<xsl:value-of select="$coor1" />
</xsl:for-each>
</table>
</table>
Use:
<td onclick="location.href='/vakman/default.asp?name={veld[5]}'"
style="cursor:pointer" valign="top" height="100%">
Explanation: The use of AVT (Attribute Value Templates) is recommended whenever the name of the attribute is statically known. It results in shorter and more readable code.
Try using the xsl:attribute
tag. you'll end up with something like this:
<td style="cursor:pointer" valign="top" height="100%">
<xsl:attribute name="onclick">location.href='/vakman/default.asp?name=<xsl:value-of select="veld[5]" />'</xsl:attribute>
精彩评论