Setting value in checkbox from DB
Hi,
I have a jsp page where I have some checkbox. Now I have hardcoded the values of the checkbox.
<html:checkbox name="CityForm" property="cityname" value="Chicago">Chicago</html:checkbox>
<html:checkbox name="CityForm" property="cityname" value="Newyork">Newyork </html:checkbox>
But what I need to do is I have to set the values Newyork , Chicago from DB. I have got those names from DB and I am having as a String[]. But I dont know how to write the code in jsp page by iterating the value.
Can anyone please help me to do that? Also please let me know good online source where I can get information like this.
Thanks
[704 byte] By [
laks77a] at [2007-10-2 6:42:30]

No, I was asking abt using the logic iterate tag. anyway I have found the solution and it works fine.
But having a new problem. I will be having 15 checkboxes and I show them in a html table . Initially while I was hardcoding, I showed 3 checkboxes in a row and so totally 5 rows.
Now I dont know how to do that. Here is the code which im using.
<tr >
<logic:iterate name="CityForm" property="cityNamesArr" id="cityname">
<td class="tbl1" align="left" valign="top">
<html:checkbox property="city">
<bean:write name="cityname"/>
</html:checkbox>
</td>
</logic:iterate>
</tr>
All the checkbox comes in a single row. I know im missing a simple logic. I am also working on it. Please let me know what could be done
Thanks
Yeah...I also got it!! Thanks a lot for the reply..but I didnt use index I set a counter.
<%! int j = 0; %>
<tr >
<logic:iterate name="CityForm" property="cityNamesArr" id="cityname">
<% if((j%3)==0) { %>
</tr> <tr> <% } %>
<td class="tbl1" align="left" valign="top">
<html:checkbox property="city">
<bean:write name="cityname"/>
<% j++ ;%>
</html:checkbox>
</td>
</logic:iterate>
</tr>
Thanks a lot!!