JSFiddle - React, Tailwind, and code Playground
HTML
<div id='blah'>
</div>
JavaScript
$(document).ready(function() {
var headers = '"ID";"Date";"Time";"Status"';
var lines = [
'"1";"2013.01.01";"10:03 AM";"Active"',
'"1";"2013.01.05";"07:45 AM";"Active"',
'"2";"2013.01.03";"9:12 PM";"Active"',
'"2";"2013.01.11";"6:37 AM";"Inactive"',
'"1";"2013.01.22";"12:57 PM";"Inactive"'
];
// these contain the name of the field you want to search in
// as defined by your header and the value to search for.
var searchField = 'ID';
var searchForThisValue = 1; // this would be a parameter in your code
var endResult =[]; // this is the stored result
var fieldIndex = -1;
// as long as your headers are in the same order as your fields,
// (and why wouldn't they be?) this will work
$.each(headers.split(';'), function(index) {
if( this.replace(/["']/g, "") == searchField ) {
fieldIndex = index;
}
});
$.each(lines, function() {
var fields = this.split(';'); // split up by semicolon
// strip the quotes around around the numbers
if(fields[fieldIndex].replace(/["']/g, "") == searchForThisValue) {
endResult.push(this);
}
});
// do whatever you want with your result, here I have just thrown
// them into an element with the id of 'blah'
$.each(endResult, function() {
$('#blah').append(this + '<br/>');
});
});