Re: [xsl] How to call Javascript function from xsl

Subject: Re: [xsl] How to call Javascript function from xsl
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Tue, 23 Jul 2002 19:16:18 +0200
Hello Charles,

your problem has nothing to do with XSLT. You don't want "to call Javascript function from xsl", but getting the javascript to work in the resulting HTML code. If you know the code works in IE, it can't be a XSLT problem, but a js problem; so it's off topic.

What I can see in your code, is a missing semicolon after the alert, but I think, it's only a typo. But what is "document.Modify"?? Did you see the alert in NS?

What version of Netscape are you using? Try the latest Mozilla release (1.0 or 1.1 beta) to be sure of best support of XSLT, js and so on. There you have a very helpful "Javascript Console" to find out possible JS errors.

Furthermore you can use attribute value templates for your code:

<select onChange="on_change()" name="logType">
  <xsl:for-each select="LOG">
    <option value="{@TYPE}">
      <xsl:if test="@TYPE=$logType">
        <xsl:attribute name="SELECTED"/>
      </xsl:if>
    <xsl:value-of select="@TYPE"/>
    </option>
  </xsl:for-each>
</select>

Regards,

Joerg

charles wrote:
Hi ,

I am trying to call javascript function "on_change()" from my xsl
code.It works fine in IE but not in Netscape.Why is it ?? Can
anyone solve my issue .

My xsl code :

<xsl:template match="LOG-LEVELS">

<script language="text/JavaScript">
            function on_change() {
   alert("onchange")
    document.logForm.Modify.value=document.Modify;
    document.logForm.submit();
            }
</script>

<form name="logForm" >
<table>
<tr><td ><b><font >Configuring logging </font> </b> </td> </tr> </table>

<table ><tr><td>

<select onChange="on_change()">
<xsl:attribute name="name"><xsl:value-of
select="'logType'"/></xsl:attribute>
<xsl:for-each select="LOG">
    <option>
    <xsl:attribute name="value"><xsl:value-of
select="@TYPE"/></xsl:attribute>
    <xsl:if test="@TYPE=$logType"><xsl:attribute
name="SELECTED"/></xsl:if>
    <xsl:value-of select="@TYPE"/>
    </option>
</xsl:for-each>

</select>

</td></tr></table>

</form>

</xsl:template>



Thanks in advance,
Charles Vijay


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


Current Thread