Click to See Complete Forum and Search --> : XSL Looping - equiv of i+1


mattisimo
02-06-2004, 05:06 AM
Hi,

I am trying to loop through the instances of a node in an XML document, creating a checkbox for each instance. The name of the checkbox has to be a number, starting at 1 and increasing by one each time.

I think this is done using a param but getting the value to increase by one each instance is proving to be a problem.

Thanks for the help,

Matt :confused:

crh3675
02-08-2004, 08:50 PM
I do not think that you can name an object with a number. I could be wrong but it is not normally done. First, I would recommend changing your naming conventions in some manner like:

cb1

Then you can loop in XSL like this:



<xsl:for-each select="item">
<xsl:element name="input">
<xsl:attribute name="type">checkbox</xsl:attribute>
<xsl:attribute name="name"><xsl:text>cb</xsl:text><xsl:value-of select="position()"/></xsl:attribute>
</xsl:element>
</xsl:for-each>

mattisimo
02-09-2004, 04:06 AM
Thanks crh3675,
Makes a lot of sense.
Matt