she*_*rry 4 jsp loops for-loop html-table
在一个jsp我有一个表,我在这样的循环中创建的行,
<table>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Actions</th>
</tr>
<tr>
<%
String[] cartItems = (String[]) request.getSession().getAttribute("cartList");
for (int i = 0; i < cartItems.length; i++) {
%>
<td>
<input type="text" id="itemPrice" maxlength="5" size="5" style="border:none;" value="$<%= cartItem[3]%>" />
</td>
<% } %>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
假设添加了5个这样的行,每行都有id = itemPrice,但我希望行包含:
id=itemPrice1
id=itemPrice2.. and so on..
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?请帮忙..
<input type="text" id="itemPrice<%=i%>" maxlength="5" size="5" style="border:none;" value="$<%= cartItem[3]%>" />
Run Code Online (Sandbox Code Playgroud)
注意"id"发生了什么.这只是句子中的反击.