This is my first time using list.js and for some reason it is not working.
Here is a live example. http://hartslogmuseum.com/bookhjr10/test.php here is what its supposed to do http://listjs.com/examples
And here is my code. I want to search only the name.
<div class="table-responsive">
<div id="catalog">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">
Sort Name
</button>
<button class="sort" data-sort="cat">
Sort Category
</button>
<h2> Catalog </h2>
<table class="list table-bordered table-striped">
<tr>
<td> <h2 class="name">Item Name</h2> </td>
<td><h2 class="cat">Item Category</h2></td>
<td> <h2>Thumbnail</h2></td>
<td> <h2 class="descr">Item Desc</h2> </td>
<td> <h2 class="time">Time Frame</h2> </td>
<td> <h2 class="donor">Donor</h2> </td>
</tr>
$resultSet = mysqli_query($conn,"SELECT * FROM bookhjr10_items");
While($row = mysqli_fetch_array($resultSet))
{
$i=0;
echo "<tr>";
echo "<td class=\"name\">".$row['name']. "</td>";
echo "<td class=\"cat\">".$row['category']. "</td>";
echo "<td><a href=\"fullimage.php?id=".$row['id']."\" data-lightbox=\pic\"><img src=\"image.php?id=".$row['id']."\" alt=\"thumb-1\" /></a></td>";
echo "<td class=\"descr\">". $row['descr'] . "</td>";
echo "<td class=\"time\">". $row['time'] . "</td>";
echo "<td class=\"donor\">". $row['donor'] . "</td>";
echo "</tr>";
$i++;
}
?>
</table>
</div>
</div>
<script type="text/javascript">
var options = {
valueNames: [ 'name' ]
};
var hackerList = new List('catalog', options);
</script>
When using list.js with tables you should add
class="list"
to a<tbody>
tag instead of the<table>
tag.So in your code change this part:
to
And don't forget to add a
</tbody>
.