简体   繁体   中英

XSL OnChange Javascript Function not Defined

If I select anything from dropdown menu, javascript function showLeague is not called and throws an error: Uncaught ReferenceError: showLeague is not defined

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
    method="html"
    omit-xml-declaration="yes"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    indent="yes"></xsl:output>
<xsl:param name="tsid" /> 


<xsl:template match="spocosy">      

    <form>
    Select a League:

    <select>
    <xsl:attribute name="name">
        <xsl:value-of select="cds"/>
    </xsl:attribute>

    <xsl:attribute name="onchange">
        showLeague(this.value)
    </xsl:attribute>


    <option value="">Leagues:</option>
    <xsl:for-each select="standing">
    <option>
    <xsl:attribute name="value">
        <xsl:value-of select="@id"/>
    </xsl:attribute>
    <xsl:value-of select="@league"/>
    </option>
    </xsl:for-each>  
    </select>
    </form>

    <div id="txtHint"><b>League info will be listed here...</b></div>
</xsl:template>

showLeague function is defined in the head tag and without xsl it is working without any problem. Any help would be appreciated. If you want to observe html output here is the url: http://tipslator.com/Table/deneme/

The document http://tipslator.com/Table/deneme/ contains an iframe http://tipslator.com/xsl/getleaguename.php with a HTML document which seems to be the XSLT result. That iframe document does not define any script function at all so any call to a function will give an error, unless you make sure the functions are defined in the iframe (or you call up parent.functionName to call functions define in the parent window).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM