I am completely new to Datatables, but think its use may solve my problem.
I am completely new to Datatables, but think its use may solve my problem.
![baz](https://secure.gravatar.com/avatar/cd61de4bbdafb484d98df0edec8789db/?default=https%3A%2F%2Fvanillicon.com%2Fcd61de4bbdafb484d98df0edec8789db_200.png&rating=g&size=120)
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Answers
I have an html table with 4 rows and 4 columns, as shown below.
At present, selecting "1000" in the length searchbox correctly returns the 2 rows matching that search term.
However, I wish to find values in the length field greater than or less than an entered value, so that "1500" returns "2000" when I click something or the 2 rows containing "1000" if I click something else.
I thought of adding either two checkboxes that return "y" or "n" if checked, or a dropdown menu. The questions are: which is better, and how do I change the existing code to get the desired result?
Being relatively new to JS/JQuery, I cannot develop the code for greater or less, and I cannot think how to link this to the checkboxes or dropdown. This is where Datatables should help. The code below will need modifying to include:
new DataTable.Editor( {
table: '#data_table'
} );
and
$editor->where( 'length', 1000, '>' );
This is the current working html and JQery code:
<!DOCTYPE html>
<html>
<head>
</head>
<body bgcolor="AED6F1">
<div class="sticky">
<center>
Search Strain Data
Please see the help for further details.
```
function searchTable() {
// Get the search input values
var name = document.getElementById("name").value.toLowerCase();
var strain = document.getElementById("strain").value.toLowerCase();
var accession = document.getElementById("accession").value.toLowerCase();
var length =
document.getElementById("length").value.toLowerCase();
// Get the table and rows
var table = document.getElementById("data_table");
var rows = table.getElementsByTagName("tr");
</html>
I think that what you need is DT's Searchbuilder, which easily enables "range" searches.
https://datatables.net/extensions/searchbuilder/
Thanks for this - I'll try.