Reputation: 500
I have a String array. I want to create a table using the strings, their postion and a radio button for each row. For example:
String a="abc&def&ghi&";
String b[]=a.split("&");
Using the string array b[]
I want my page to display a table like this:
o --> radio button
--------------------
| num | items |
--------------------
| o 0 | abc |
--------------------
| o 1 | def |
--------------------
| o 2 | ghi |
--------------------
I tried using a for
loop in a scriplet to generate the rows but if I do so, I cannot get the value of a particular radio button.
Can someone give me some idea on how to achieve this with JSTL or other methods?
Upvotes: 1
Views: 1889
Reputation: 379
I think this is what you want...
<%! int i = 0; %>
<c:forEach var="element" items="${string_array}">
<tr>
<td><input type="radio" value="<%= i++ %>" name="item_radio">${element} </td>
</tr>
</c:forEach>
Upvotes: 2