This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: javascript for loop inside xsl template
- From: Greg Faron <gfaron at integretechpub dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 03 May 2002 17:26:27 -0600
- Subject: Re: [xsl] javascript for loop inside xsl template
- Reply-to: xsl-list at lists dot mulberrytech dot com
At 12:54 PM 5/3/2002, you wrote:
>I was wondering if anybody could tell how to write a
>javascript for loop inside an xsl template.
>
>
><xsl:template match="principle">
>for (intIndex = 1; intIndex < dependentObjectArray.length;
>intIndex++)
>{
> if ( dependentObjectArray[intIndex].value == intValue )
> {
> dependentObjectArray[intIndex].disabled = true;
> }
> else
> {
> dependentObjectArray[intIndex].disabled = false;
> }
>}
></xsl:template>
>
>It's blowing up on < in the for loop condition.
As Thomas pointed out, you can reverse the test to read
for (intIndex = 1; dependentObjectArray.length > intIndex; intIndex ++)
[JavaScript note: Do you mean to start at 1 or at 0?]
or you can write it the way you're comfortable and enclose the entire thing
in a <![CDATA[ ]]> section.
<xsl:template match="principle">
<![CDATA[
for (intIndex = 1; intIndex < dependentObjectArray.length; intIndex ++)
{
if (dependentObjectArray[intIndex].value == intValue)
dependentObjectArray[intIndex].disabled = true;
else
dependentObjectArray[intIndex].disabled = false;
} // ends for
]]>
</xsl:template>
Greg Faron
Integre Technical Publishing Co.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list