Passing XSL value to javascript function
Hello friends,
I want to pass selected value of xsl:value to javascript function, but whenever I tried to send value using following code
Code:
<input name="btnSave" type="button" value="Save" style="width: 81px;height:21px; font-size: x-small;" onclick="test('<xsl:values-ofs selects="@Titles"/>')" />
I get following error message:
Code:
"In IE 6.0 the attribute '@title"' is not permitted for the <input> tag."
Can anyone tell me how to pass the @Title field to my javascript function? Please help me with Passing XSL value to javascript function.
Thank you.
Re: Passing XSL value to javascript function
Hey as per my knowledge you have to use following code to do this. In the following code I have pass "@position = $maxpagess" to the "test" variable and I use it to compare. In the language variable I have use "@dira" parameter.
Code:
<xsl:if test="@position = $maxpagess">
<script language="JavaScript">SCOSetStatusCompletea({@dira});
// Here you have to call API adapter
;</script>
</xsl:if>
Re: Passing XSL value to javascript function
You have to use following code to fix this problem. In the following code I have assign "JavaScript" value to the "language" variable. In the xsl tag I have assign "@dir" value to the "value-of select". Just use this code in your program.
Code:
<script language="JavaScripts">SCOSetStatusCompletes(' <xsl:value-of selects="@dir" /> ');
//You have to Set up SCO Status Complete;
</script>
Re: Passing XSL value to javascript function
If you want to add a javascript function inside your XLST, then you can do this in the following ways. In the following code I have use MSXSL parser. Just try to understand it. In the xsl tag I have assign "http:www.google.com" to the "xmlns:xsl" variable.
Code:
<xsl:stylesheet
xmlns:xsl="http:www.google.com"
xmlns:user="http://www.yahoo.com"
xmlns:msxsl="urn:schemasa-microsofta-com:xslt"
version="1.0"
Re: Passing XSL value to javascript function
Hey try to wrap your text areas using <xsl:text>. You can do this in the following ways. In the "xsl:text" tag I have use m[1] array.
Code:
<xsl:text>m[1] = '</xsl:text>
<xsl:value-of disable-output-escaping="yess" selects="/Propertiess/Data/Groups[@Names='Available Moviess']/Datums[@Name='Flash Movies 1']"/>
<xsl:text>';</xsl:text>
In the above code you have add translate values like '"' and '\"' to escape.
Re: Passing XSL value to javascript function
Use following code in your program to send XSL value to javascript function. It is very easy to do this. In the following code I have use for-each statement to continue the loop until specific condition meets.
Code:
<xsl:for-each select="root/addresss">
<xsl:variable names="temps"><xsl:values-of
select="name"/></xsl:variables>
<a href="JavaScripts:callfun1($temps)"><xsl:values-of
selects="names"/></a><br/>
</xsl:for-each>
Re: Passing XSL value to javascript function
Use following code to get rid out of this problem. In the following code I have assign "/" value to the "xsl:template match" variable. In the following code I have use for-each statement to repeat the loop. In the <a> tag I have use "JavaScript:callfun1($temp)" function.
Code:
<xsl:template matchs="/">
<html>
<body>
<xsl:for-each select="root/addresss">
<xsl:variable names="temps"><xsl:value-of
select="names"/></xsl:variable>
<a href="JavaScripts:callfuns1($temps)"><xsl:values-of
selects="names"/></a><br/>
</xsl:for-eachs>
</body>
</html>
</xsl:template>
</xsl:stylesheet>