【发布时间】:2019-07-06 06:18:18
【问题描述】:
我可以通过 id 获取 jsp 页面中项目的单个值。但我无法获得复选框值。如何通过 id 或其他任何内容获取复选框值。当我点击订单页面时,它将收集所有产品名称和产品价格
截图
<table class="table table-hover table-striped">
<thead>
<tr>
<th>ID</th>
<th>Choose Product</th>
<th>Product Name</th>
<th>Product Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%
String Host = "jdbc:mysql://localhost:3306/shopbilling";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(Host, "root", "");
statement = connection.createStatement();
String query = request.getParameter("q");
String data;
if(query != null)
{
data = "select * from products_tbl where product_name like '%"+query+"%' or product_price like '%"+query+"%'";
}
else
{
data = "select * from products_tbl";
}
rs = statement.executeQuery(data);
while (rs.next()) {
%>
<tr>
<td><%=rs.getString("id")%></td>
<td> <input type="checkbox" /> </td>
<td><%=rs.getString("product_name")%></td>
<td><%=rs.getString("product_price")%></td>
<td class="text-center" width="250">
<a href='edit.jsp?u=<%=rs.getString("id")%>' class="btn btn-warning">Edit</a>
<a href='delete.jsp?d=<%=rs.getString("id")%>' class="btn btn-danger">Delete</a>
</td>
</tr>
<%
}
%>
</tbody>
</table>
<a href='order.jsp' class="btn btn-success">Order</a>
【问题讨论】: