[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

javascript in XSLT

Subject: javascript in XSLT
From: Ming <myu@xxxxxxxx>
Date: Mon, 29 Apr 2002 16:03:05 -0600
javascript in xslt stylesheet
Hi,

I really have some trouble on my javascript in my stylesheet.  What I
need to
do in the javascript in my stylesheet is, to access the elements using
the
form's name and checkbox's name.

Thanks a lot for your help.

Here are the portions of my stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xalan="http://xml.apache.org/xalan"
      version="1.0">

  <xsl:output method='html'/>
  <xsl:include href="markRecords.xsl" />   <!-- the javascript is in
this
stylesheet , attached after this stylesheet-->

  <xsl:template match="Results">
        <html>
       <head>
        <title>Search Results </title>
      </head>
     <xsl:call-template name="markRecords" />   <!-- Here, I am trying
to call
the javascript -->
      <body>
        <xsl:apply-templates select="result">
        </xsl:apply-templates>
       </body>
    </html>
  </xsl:template>


<xsl:template match="result">
    <xsl:variable name="key">
       <xsl:value-of select="./Key" />
    </xsl:variable>

    <form name="results">
         <input name="marks" type="checkbox"  onClick='saveme("{$key}",
this.checked)' /> <br/>
    </form>
</xsl:template>


Here is the markRecords.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:template name="markRecords">
   <script>
      function saveme(key, value) {<![CDATA[
         var script, i, num, temp;
         num = document.results.length;

         alert("total elements is " + document.results.length);   //
note,
this works just fine, say total elements is 5  ( 5 searching results)

         for ( i = 0; i < num; i ++ ) {
           temp = document.results.marks[i].type;

// note, results is the name of the form, marks is the name of the
checkboxes,
but here is the problem,
// the javascript gives me error:
//document.results.marks[i] has no properties.

           alert("element " + i  "'s type is " + temp);
         }

        ]]>
  </script>
</xsl:template>

</xsl:stylesheet>


Thanks again for your help.

Ming




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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.