I have JSP page which displays the records fetched from mysql through java servlet. Now I want filter the obtained records using jquery. I used the following code with head section of jsp page
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.min.js">
</script><script type= "text/javascript">{$(document).ready(function()
{$("#searchInput").keyup(function() {
var rows = $("#fbody").find("tr").hide();
var data = this.value.split(" ");
$.each(data, function(i, v) {
rows.filter(":contains('" + v + "')").show();
});
})})};
</script>
The code for getting the records from servlet and displaying it in the JSP is given below
<body><input id="searchInput" ><br/>
<TABLE align="Center" border="1px" width="80%">
<thead>
<tr><th><b>User_ID</b></th>
<th><b>User_Name</b></th>
<th><b>Password</b></th>
<th><b>Designation</b></th>
</tr>
</thead>
<%Iterator itr;%>
<%List data=(List) request.getAttribute("UserData");
for(itr=data.iterator();itr.hasNext();)
{%>
<tbody id="fbody">
<tr>
<% String s= (String) itr.next(); %>
<td><%=s %></td>
<td><%=itr.next() %></td>
<td><%=itr.next() %></td>
<td><%=itr.next() %></td>
<form id="edit" action="EditRecord" method="post" >
<td><input type="hidden" name="hidden_edit" id="edit_id" value="<%=s %>"/>
<input type="submit" value="Edit" name="edit"> </td>
</form>
<td><form id="delete" action="DeleteRecord" method="post" >
<td><input type="hidden" name="hidden_delete" id="delete_id" value="<%=s %>"/>
<input type="submit" value="delete" name="delete"> </td>
</form></td>
<%} %>
</tr>
</tbody>
</TABLE></body>
I am able to get all the records but the script is not filtering my record. Dont know where is the problem.Could any one help me out please.