Re: [xsl] javascript in XSLT

Subject: Re: [xsl] javascript in XSLT
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Apr 2002 16:27:45 -0600
At 03:57 PM 4/29/2002, you wrote:
<xsl:template match="Results">
  <html>
    <head>
      <title>Search Results </title>
    </head>
    <xsl:call-template name="markRecords" />

The JavaScript should really go between the <head> and </head> tags. Move the call-template up one line.


    <body>
      <xsl:apply-templates select="result" />
    </body>
  </html>
</xsl:template>

I assume (you provided no XML data, but I gather from your comments) that there are 5 "result" elements in your XML. If this assumption is incorrect, this means that there will be several <form name="results" ...> in your output. This is incorrect for your purpose, as the name document.results would not be unique. It seems to be the case though, since you say that document.result.length is 5, when document.result.marks.length should have the value 5.


I recommend you alter the templates to output only one <form> element, and a single checkbox for each result (if I'm assuming your data correctly). This would look like the following (I also changed your onclick attribute slightly):

<xsl:template match="Results">
<html>
<head>
<title>Search Results</title>
<xsl:call-template name="markRecords" />
</head>
<body>
<form name="results">
<xsl:apply-templates select="result" />
</form>
</body>
</html>
</xsl:template>
<xsl:template match="result">
<xsl:variable name="key" select="Key" />
<input name="marks" type="checkbox" onclick="saveme('{$key}', this.checked);" />
<br />
</xsl:template>



Greg Faron Integre Technical Publishing Co.



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


Current Thread