0
So my people, first of all, I’d like to say that I’m a beginner and I started learning this week so take it easy on me, please u.u
So I’m going through a test site here and I have the following situation: I have three employees and each of them worked a certain amount of hours a day. This information is all in a comic.In the script, the names of the employees are identified by: Obj[1][i]. name and hours worked are identified by Obj[1][i].horas. What I want to do is sum up all the hours that each employee worked and show them in their respective column.
Well, I tried to do the following:
I created an array with the names of the employees to compare with the names of the database and if the names are equal, the hours will be added up by then and I don’t know how to make it appear in the table. I don’t know if what I did is right (probably not) but I tried the part of the code where I did it is here:
if (Obj !== null) {
if (Obj[0].tipo === 1) {
var data = [];
nomes = new Array ("Alex", "Yamilla", "Fernanda");
jQuery("#status_projetos").html("");
jQuery("#resumo_alocacao").html("");
for(var x = 0; x < nomes.length; x++ )
{
soma = 0;
for (var i = 0; i < Obj[1].length; i++) {
var obj = {
label: Obj[1][i].nome_projeto,
data: Obj[1][i].horas
};
if(nome == Obj[l][i].nome)
{
soma+=horas;
}
}
ps: ignore where it says Obj[1][i]. project name, that’s another thing. If you can help beauty, if not, ok tbm :)
Welcome to Stackoverflow, you could add the HTML code snippet that shows you build this table?
– Lucas Duete