I'm new to XSLT and I'm trying to link text boxes and check boxes in a loop. The problem I have is that all check boxes are linked to the first textbox because of link between the text box id and the checkbox name. I read that I can get the index of the loop from using position(). But how can I get the value of position and concatenate it to the id and name of the text box and checkbox?
Any suggestions?
<xsl:for-each select="plants">
<tr>
<td>
<input type="text" class="form-control" id= "plantName" name="//pn:plants/pn:plantName" disabled="disabled" maxlength="16"/>
</td>
<td>
<div class="checkbox">
<label>
<input type="checkbox" name="plantName"/> Edit name
</label>
</div>
</td>
</tr>
</xsl:for-each>
Use an attribute value template in the form of <input type="checkbox" name="plantName{position()}"/>
to compute the name as a concatenation of the static string plantName
and the current value of position()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.