xsl-list
[Top] [All Lists]

Re: How can I put some javascript into an xslt page

2003-06-17 09:41:37
Hi Lionel,

Here is what I tried but the value nbuser is not found.

<xsl:template match="users">
<xsl:variable name="nbuser">hello</xsl:variable>
  <script language="javascript">
    function lionel() {   document.write(string($nbuser)); }
  </script>
  <script language="javascript">lionel();</script>
...

I think that you're trying to produce the output:

  <script language="javascript">
    function lionel() { document.write('hello'); }
  </script>
  <script language="javascript">lionel();</script>

and you want the "hello" bit to come from the value of the $nbuser
variable, as declared in XSLT. To get the value of a variable, use
<xsl:value-of>:

  <xsl:value-of select="$nbuser" />

Place this instruction in the place where you want the value of the
variable to appear within the HTML that you're generating:

  <script language="javascript">
    function lionel() { document.write('<xsl:value-of select="$nbuser" />'); }
  </script>
  <script language="javascript">lionel();</script>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>