0
- 以下是我的html代码。我使用
<sql:...>
从数据库获取数据,并使用<c:forEach ...>
进一步迭代,并将数据 作为tr
内的文本框中的值。 - 现在我想对这样的表执行动态搜索操作。我 尝试了一些使用jquery的代码,但它似乎只在将数据添加到我的 tr时直接工作,如
<tr>${row.barcode}</tr>
。该代码不适用于<td> <input type="text" value="${row.barcode}"> </td>
。
products.html放在将HTML文本框作为tr中的数据。如何在搜索字符串输入时对这样的表执行动态搜索操作?
<html>
<label for="search">Search products :</label>
<input type="text" id="search" placeholder="Enter text to search">
<!-- Fetch table data -->
<sql:setDataSource var="myDataSource" driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@10.1.56.49:1521:something" user="something" password="something"/>
<sql:query var="result" sql="select * from garageproducts" dataSource="${myDataSource}"/>
<table id="mytable">
<thead>
<tr>
<th>Mark</th>
<th>Barcode</th>
<th>Name</th>
<th>Brand</th>
<th>Stock</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<c:forEach var="row" items="${result.rows}">
<tr>
<td> <input type="checkbox"> </td>
<td> <input type="text" value="${row.barcode}"> </td>
<td> <input type="text" value="${row.name}"> </td>
<td> <input type="text" value="${row.brand}"> </td>
<td> <input type="text" value="${row.stock}"> </td>
<td> <input type="text" value="${row.cost}"> </td>
</tr>
</c:forEach>
</tbody>
</table>
</html>