开发者

How to get cell data of specific row from the dynamically created HTML table?

开发者 https://www.devze.com 2023-01-17 19:00 出处:网络
How to get cell data of a specific row from the dynamically created HTML table in JSP? I am creating JSP Page in the following way

How to get cell data of a specific row from the dynamically created HTML table in JSP?

I am creating JSP Page in the following way

  1. Connect to MySQL Databse
  2. Fetch rows from table based on criteria
  3. Construct HTML table dybamically based on the rows returned in step 2
  4. The first column of table contains checkbox
  5. JSP page contains a S开发者_C百科ubmit button
  6. Select checkbox for some row(s)
  7. On Submit button click, How can i check which row checkbox is selected?


Give all checkboxes the same name, but a different value, e.g. the row ID.

<table>
    <c:forEach items="${list}" var="row">
        <tr>
            <td><input type="checkbox" name="rowid" value="${row.id}"></td>
            <td>${row.name}</td>
            <td>${row.value}</td>
            ...
        </tr>
    </c:forEach>
</table>

Then you can obtain the checked ones in the server side using HttpServletRequest#getParameterValues() as follows:

String[] rowids = request.getParameterValues("rowid");
// ...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号