How can I call this javascript function in xsl?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lmsook
    New Member
    • Sep 2008
    • 2

    How can I call this javascript function in xsl?

    Hello,
    Please forgive me that I posted same question on several forums, but I haven't got answer yet.

    My problem is that I need to add calendar javascript widget in xsl file.


    First I have Calendar javascript I used before, and
    Here is the html file that used calendar javascript I used before.



    Code:
    <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> New Post </title>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1 "/>
    <script type="text/javascript" src="calendarDateInput.js">
    /***********************************************
    * Jason's Date Input Calendar- By Jason Moon http://calendar.moonscript.com/dateinput.cfm
    * Script featured on and available at http://www.dynamicdrive.com
    * Keep this notice intact for use.
    ***********************************************/
    </script>
    </head>
    <body>
    ....
    <label>On Date : </label>
    <script>DateInput('onDate', true, 'YYYY-MM-DD', '<?=shownDate($onDate);?>')</script>
    ...
    </body>
    </html>


    And here is the xsl file I tried to add java script


    Code:
    <xsl:template match="node()" mode="head">
    <head>
    <script type="text/javascript">
    <xsl:attribute name="src">calendarDateInput.js</xsl:attribute>
    <xsl:comment>Comment added so script is recognised</xsl:comment>
    </script>
    
    </head>
    </xsl:template>
    
    <xsl:template name="report-params-dates">
    <!-- Start Date We use calendar widget -->
    <label for="start" id="start_label"> 
    <xsl:text>Start Date: </xsl:text>
    <script>DateInput('onDate', true, 'YYYY-MM-DD')</script> 
    </label>
    </xsl:template>
    The result? There is no calendar shown and said there is error in that page. I know I didn't do correctly, but I don't know how to fix it.

    I really appreciate your help.

    Thanks,
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    You've added the <script> tag inside the <label>
    Pretty sure you didn't want to do that.

    Also:Why even use an <xsl:attribute> ? Why not just:
    <script type="text/javascript" src="calendarDa teInput.js">

    Comment

    • lmsook
      New Member
      • Sep 2008
      • 2

      #3
      I tried as you suggested in both ways,
      but it still doesn't work....

      Comment

      Working...