我在树枝文件中制作了一个表格,我想通过循环填充数据,但我的字段名称相同,所以我想在每个字段名称上附加一个计数器变量,我该怎么做?
这是我的代码:
<div id="table">
<table class="table table-bordered">
<thead>
<tr>
<th style="text-align:left; width:120px;">Item</th>
<th style="text-align:left; width:200px;">Description</th>
<th style="width:100px;">Unit Cost</th>
<th style="text-align:right; width:60px;">Qty</th>
<th style="text-align:left; width:100px;">Tax</th>
<th style="text-align:left; width:100px;">Tax</th>
<th style="text-align:right; width:100px;">Line Total</th>
</tr>
</thead>
<tbody>
{% for items in itemdata %}
<tr>
<td colspan=7 width=800>
<select class="items" name="items" style="width:127px; float:left;" id="items"><option value="1" selected="selected" disabled="disabled"></option></select>
<textarea name="description" id="description" class="description" style="float:left; display: block; height: 30px; width:209px; border-radius:0px; margin: -1px 1px 0;">{{ items.description }}</textarea>
<input type="text" name="unitprice" id="unitprice" class="unitprice" value="{{ items.unitPrice }}" style="float:left; display:block; height:30px; width:106px; border-radius:0px; margin:-1px -1px 0;">
<input type="text" name="quantity" id="quantity" class="quantity" value="{{ items.quantity }}" style="float:left; display: block; height: 30px; width:64px; border-radius:0px; margin: -1px 1px 0;">
<select name="firsttax" id="firsttax" style=" float:left; display: block; height: 31px; width:106px; border-radius:0px; margin: -2px -1px 0;"><option value="1" selected="selected" ></option></select>
<select name="secondtax" id="secondtax" style="float:left; display: block; height: 31px; width:107px; border-radius:0px; margin: -2px 0px 0;"><option value="1" selected="selected"></option></select>
<input type="text" name="linetotal" id="linetotal" class="linetotal" value="{{ items.linetotal }}" placeholder="0.00" readonly style="float:right; display: block; height: 31px; width:107px; border-radius:0px; background-color: #F0F0F0; text-align:right; margin: -31px -1px 0;">
</td>
</tr>
<input type="hidden" id="itemscounter" name="itemscounter" value=""/>
{% endfor %}
我的字段名称相同这里是截图:
如何更改描述,描述2,描述3,描述4等字段名称......
在哪里
itemscounter value = number of rows