Javascript in xsl
-
Hi All, I would like to load a java script array dynamically inside xsl. Suppose I have the following xml <srsource> <individualsr> <srid>srid1</srid> <srothervalue>srothervalue1</srothervalue> </individualsr> <individualsr> <srid>srid2</srid> <srothervalue>srothervalue2</srothervalue> </individualsr> </srsource> What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded. test['srid1'] = 'srothervalue1' test['srid2'] = 'srothervalue2' and so on.. Could anyone tell me how the above piece of code can be included inside xsl:for-each? Thanks Ashvish
-
Hi All, I would like to load a java script array dynamically inside xsl. Suppose I have the following xml <srsource> <individualsr> <srid>srid1</srid> <srothervalue>srothervalue1</srothervalue> </individualsr> <individualsr> <srid>srid2</srid> <srothervalue>srothervalue2</srothervalue> </individualsr> </srsource> What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded. test['srid1'] = 'srothervalue1' test['srid2'] = 'srothervalue2' and so on.. Could anyone tell me how the above piece of code can be included inside xsl:for-each? Thanks Ashvish
Ashvish wrote:
What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded.
Ashvish wrote:
Could anyone tell me how the above piece of code can be included inside xsl:for-each?
Not sure I understand your question. I mean whatever you put inside the xsl:for-each is output into the result so like:
<xsl:for-each select="*/individualsr">
test['<xsl:value-of select="./srid"/>'] = '<xsl:value-of select="./srothervalue"/>';
</xsl:for-each>led mike
-
Ashvish wrote:
What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded.
Ashvish wrote:
Could anyone tell me how the above piece of code can be included inside xsl:for-each?
Not sure I understand your question. I mean whatever you put inside the xsl:for-each is output into the result so like:
<xsl:for-each select="*/individualsr">
test['<xsl:value-of select="./srid"/>'] = '<xsl:value-of select="./srothervalue"/>';
</xsl:for-each>led mike
Thanks for the reply. What I am really trying to do is something like <xsl:variable name="user" select="Login/UserInfo/UserName"/> <SCRIPT language="JavaScript"> <![CDATA[ ... rowA = new Object() rowA.data1 = ']]><xsl:value-of select="$user" /><![CDATA[' rowA.data2 = 'needs' rowA.data3 = 'help' myTable.append_row(rowA) ... ]]> </SCRIPT> This works in Mozilla but not in IE. What could be the reason?
-
Thanks for the reply. What I am really trying to do is something like <xsl:variable name="user" select="Login/UserInfo/UserName"/> <SCRIPT language="JavaScript"> <![CDATA[ ... rowA = new Object() rowA.data1 = ']]><xsl:value-of select="$user" /><![CDATA[' rowA.data2 = 'needs' rowA.data3 = 'help' myTable.append_row(rowA) ... ]]> </SCRIPT> This works in Mozilla but not in IE. What could be the reason?