简体   繁体   中英

how set the value of check box getting from arraylist objects

I'm processing a multi form page from jsp. And I have to display checkbox in table format having value=id which is getting from ResultSet in ArrayList object. So my question is how to display check box with each row setting in value= id. And row (record) is coming from ArrayList.

The code in my JSP is :

        <center>
<div style="margin:20px 0px 0px 0px; width:1100px; height:450px; background-color:lightgray" class="divBorder ">
    <font color="#3B5998"><h3>Work Description</h3>
    <table style="margin:20px 20px 20px 20px; border:solid 2px darkGray; border-spacing:5px " border="1"></font>
    <tr><th width="20px">Select</th><th width="60px">Work Code</th>
            <th width="700px">Description</th><th width="60px">Edit</th></tr>
    <%
    Work_Manager wm=new Work_Manager();
    ArrayList<ArrayList<Object>> worklist=new ArrayList<ArrayList<Object>>();
    ArrayList<Object> list = new ArrayList<Object>();
    worklist=wm.getWork();
    Iterator<ArrayList<Object>> it = worklist.iterator();
    while(it.hasNext()){%>
        <tr>
    <%  
        list=it.next();
        Iterator<Object> itr = list.iterator();
        while(itr.hasNext()){%>
        <td>
        <%=itr.next()%></td>
        <% }%>
        <td><a href="#">Edit</a></td></tr>
    <%
    }
    %>


    </table>
    <table style="margin:20px 20px 20px 20px;">
        <tr><td><input class="btn" type="submit" value="Delete Selected List" onclick="" /></td></tr>
    </table>
</div>
</center>

Retrieve the ResultSet object from ArrayList .

Resultset rs = (Resultset) iter.next();

while(rs.next()){ 
String value = rs.getString("your column name for id");
%>
<tr>
<td><input type = "checkbox" name="abc" value="<%=value%>">
<td>....</td>
</tr>
<%
}
%>

Pass this value dynamically while creating table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM