I have Table (Employees) A:
+----+---------+
| ID | NAME |
+----+---------+
| 1 | ROBERT |
| 2 | JAMES |
| 3 | RICHARD |
| 4 | KANYE |
| 5 | DYLAN |
| 6 | JOHN |
| 7 | JEAN |
| 8 | LOKI |
| 9 | ADAM |
+----+---------+
And Table (Employees) B:
+----+---------+
| ID | NAME |
+----+---------+
| 1 | ROBERT |
| 2 | JAMES |
| 3 | RICHARD |
| 4 | KANYE |
| 5 | DYLAN |
+----+---------+
Those people are my "employees". The names from table B are all the employees on my database and the names from table A are all the employees that I've assigned to project n°1.
I would like to HIDE all names in Table B that already appear in Table A because I don't want to re-assign the same employee to project n°1.
How can I resolve this using jQuery?
a clientside check would be:
function compareLists(listA, listB){
var resultList = [];
listA.forEach(function(itemA){
listB.forEach(function(itemB){
if (itemB.name !== itemA.name)resultList.push(itemB);
}
}
return resultList;
}
or at the serverside (database):
select * from table_b where name not in (select name from table_a)
greetings
Normally you should do that on the server side using SQL
as already answered. However, since you ask about javascript. This is the way to filter it at client side:
//collect list of names in A
var table = document.getElementById("TableA");
var names = []
for (var i = 0, row; row = table.rows[i]; i++) {
names.push(row.celss[1]);
}
//check names in B
table = document.getElementById("TableB");
for (var i = 0, row; row = table.rows[i]; i++) {
if(jQuery.inArray(row.cells[1], names) !== -1){
//show row
}else{
//hide row
}
}
I have the following path: /s/STRINGINEED/abcdef/ How should I structure my regex to match STRINGINEED as a result? /s/ is a fixed path, so I would like to get any string between /s/ and the ...
I have the following path: /s/STRINGINEED/abcdef/ How should I structure my regex to match STRINGINEED as a result? /s/ is a fixed path, so I would like to get any string between /s/ and the ...
I want to call two functions passes via props on click. Note that both of them need arguments of their own. After a bit of searching on Stack Overflow, I found this solution: onclick={()=>{ f1(); ...
I want to call two functions passes via props on click. Note that both of them need arguments of their own. After a bit of searching on Stack Overflow, I found this solution: onclick={()=>{ f1(); ...
Rather than use the likes of Redis, or even LokiJS (which looks great), can I just create a large javascript collection in memory as my app runs, and query that instead?
Rather than use the likes of Redis, or even LokiJS (which looks great), can I just create a large javascript collection in memory as my app runs, and query that instead?
I am having a big array (length:10k) of coordinates (rawData = [x,y1,y2,y3,...]) as follows: rawData = [ {x: 1, y1: 1, y2: 13, y3: 2}, {x: 2, y1: 2, y2: 23, y3: 2}, {x: 3, y1: 3, y2: 33, ...
I am having a big array (length:10k) of coordinates (rawData = [x,y1,y2,y3,...]) as follows: rawData = [ {x: 1, y1: 1, y2: 13, y3: 2}, {x: 2, y1: 2, y2: 23, y3: 2}, {x: 3, y1: 3, y2: 33, ...