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

XML Element as Variable in Javascript?

Status
Not open for further replies.

impossibleroot

IS-IT--Management
Sep 18, 2001
2
US
I need to pass the contents of an XML element into a variable to be used in script, like so:

Code:
<p class=&quot;header&quot;><a href=&quot;#&quot; onclick=&quot;toggle('menuid'); return false&quot;>

The variable 'menuid' needs to be filled (many times, through a for-each recursion) by one of my XML elements. I tried:

Code:
<script>menuid = '<xsl:value-of select=&quot;BKAbr&quot;/>';</script>

but that doesn't seem to work. I know that the script works if I fill in the variable manually; now I just need to get it filled automatically, every time the (for-each) recurses.
 
Have you tried <xsl:variable> ?

<xsl:for-each...>
<xsl:variable name=&quot;menuid_param&quot;>whatever</xsl:variable>
<script>
menuid = <xsl:value-of select=&quot;$menuid_param&quot;/>
</script>
</xsl:for-each>

igor.
inakshin@sprynet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top