'How to create a search bar for my data in javascript
Following is my code that represents a 13 attribute data set fetched from a .json file in HTML and I want to apply a search bar and check box filter on it. I want the search filter to only search all type of text in the data but I can't seem to do it. The check filter I only want to apply on the company attribute.
// FETCHING DATA FROM JSON FILE
$.getJSON("laptopData.json",
function (data) {
var student = '';
// ITERATING THROUGH OBJECTS
$.each(data, function (key, value) {
//CONSTRUCTION OF ROWS HAVING
// DATA FROM JSON OBJECT
student += '<tr>';
student += '<td>' +
value.laptop_ID + '</td>';
student += '<td>' +
value.Company + '</td>';
student += '<td>' +
value.Product + '</td>';
student += '<td>' +
value.TypeName + '</td>';
student += '<td>' +
value.Inches + '</td>';
student += '<td>' +
value.ScreenResolution + '</td>';
student += '<td>' +
value.Cpu + '</td>';
student += '<td>' +
value.Ram + '</td>';
student += '<td>' +
value.Memory + '</td>';
student += '<td>' +
value.Gpu + '</td>';
student += '<td>' +
value.OpSys + '</td>';
student += '<td>' +
value.Weight + '</td>';
student += '<td>' +
value.Price_Euros + '</td>';
student += '</tr>';
});
//INSERTING ROWS INTO TABLE
$('#table').append(student);
});
});```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
