Reputation:
I'm using doctrine and php for data query from mysql table.My table looks like this Completed Overdue Ongoing
I'm using some code in action to render datas to the table.My question is is it possible to use Javascript to get the total count of each rows?This is the complete table with some datas
I want to count the datas in "Completed","Overdue","Ongoing" columns.Is it possible with Javascript?
Upvotes: 0
Views: 277
Reputation: 1485
simply you can count number of ',' in each columns for completed / overdue or ongoing
you can use this code for find number of occurrence for specific character in javascripts
var temp = "This is a string. is";
// the g in the regular expression says to search the whole string
// rather than just find the first occurrence
var count = temp.match(/is/g);
alert(count.length);
Upvotes: 1
Reputation: 598
If I understand it correctly then you want to count B-12, B17... in those columns. Yes it's possible with javascript. You can do the following steps:
You will have to research about what called DOM(Document Object Model) and how to use Javascript to handle with it. I suggest you to use Javascript library like [http://jquery.com/][1] to make thing easier
Upvotes: 0
Reputation: 422
You should put some code for a good answer
So, it is possible if you put each task completed in a different <span>
, for example lets asume the "Completed" column has the class .completed
:
for each row, count the completed:
$('tr').each(function(key, item){
var completed = $(item).find('td.completed').find('span').length;
//do something with the completed
})
Upvotes: 0