In a jsp I have a table whose rows I am creating in a loop like this,
<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>
Suppose 5 such rows are added, every row will have the id=itemPrice, but I want the rows to have:
id=itemPrice1
id=itemPrice2.. and so on..
How do I do this? Please help..
Note what happened with the “id”. It’s just the counter in the for sentence.