[英]How can I access XSL variable in javascript
我尝试了很多方法来将xsl变量访问javascript,这是我的代码,请帮助我找到解决方案
<xsl:variable name="VariableName">
<xsl:for-each select="ROW/COL/LIST-BOX/DATA">
<xsl:choose>
<xsl:when test="position() =1">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
|<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<body>
<xsl:attribute name='onLoad'>javaScript:userDetails()</xsl:attribute>
<script type="text/javascript" language="javascript">
function userDetails()
{
var title = <xsl:value-of select="$VariableName"/>;
alert(title);
}
</script>
</body>
Check following code
<xsl:variable name="VariableName">
<xsl:for-each select="ROW/COL/LIST-BOX/DATA">
<xsl:choose>
<xsl:when test="position() =1">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
|<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<body onload="userDetails()">
<script type="text/javascript" language="javascript">
function userDetails()
{
var title = "<xsl:value-of select="$VariableName"/>"
alert(title);
}
</script>
</body>
找到了...
xsl
<table>
<tr><td id="Rtest"><xsl:value-of select="$VariableName" /></td></tr>
</table>
js
var myString= document.getElementById("Rtest").innerHTML;
现在正在工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.