The following code displaying multiple checkbox with same value is the checkbox depends on the for loop. When the arr.length increases, the checkbox number for the same value will increase.
However, I do not know how to fix it.
I want to databind the data with checkbox, when member comes back, he can view the checked items. For each time of update, an array length increases, the checkbox number for the same item also increases.
<%
String sql = "SELECT s.id as id, s.cook as cook, m.cooking as e FROM cooking s join member m where m.id=" + myID;
ResultSet rs = s.executeQuery(sql);
while (rs.next()) {
String arr[]= new String [rs.getString("e").split("\\,").length];
int i;
for(i=0;i<arr.length;i++)
{
arr = rs.getString("e").split("\\,");
%>
<input TYPE=checkbox NAME="cooking" VALUE="<%=rs.getInt("id")%>" <%if(rs.getInt("id")==Integer.parseInt(arr)){out.print("checked");}%>><%=rs.getString("cook")%><BR>
<%
}
}%>