Skip to content
Advertisement

Is it possible to alter a table generated from JSON data by adding in manual data?

I am building this Table through json data fed in from a php script.

I want to go back and add in the total number of students per unique location. So for example, the row after “EOF/TRiO” will total the number of students for that location – which is 2. And the final row of “Learning Center” (before ‘Student Success Office’) will read Total – 71 students. Is this possible to do so?

This is how I am building my table (ajax):

JavaScript

JSON format:

JavaScript

Backend:

JavaScript

Thank you for any help or suggestions!

Advertisement

Answer

I think the below code can solve your problem. For each key you can calculate the total numbers of students while computing the html code. And after you calculated all the inner keys then you can add the row that shows total numbers. I didn’t have time to test it. But it should do the job.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement