Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:08:48+00:00 2026-06-10T17:08:48+00:00

I am using this jquery datatable plugin to display information from database. My table

  • 0

I am using this jquery datatable plugin to display information from database. My table looks like following. Now I am trying to sum up the marks (please check the table below) and show them as total marks just like in the example given here in this website

<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf-8">
 $(document).ready(function() {$('#gtable').dataTable();} );
  </script>

<table class="gtable" align="center" id="gtable">
<thead>
 <tr>
    <th>Sl</th>
    <th>Name</th>
    <th>Marks</th>
 </tr>
</thead>

<tbody>
 <tr><td>1</td> <td>Charlie Sheen</td>  <td>20</td></tr>
 <tr><td>2</td> <td>John Cryer</td>     <td>20</td></tr>
 <tr><td>3</td> <td>Jason Stathum</td>  <td>20</td></tr>

</tbody>

</table

The plugin’s website have provided the following code to do and show the summation but I still don’t understand how to use it my data table above.

Could you please help me with this?

  $(document).ready(function() {
  $('#example').dataTable( {
    "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
        /*
         * Calculate the total market share for all browsers in 
          this table (ie inc. outside
         * the pagination)
         */
        var iTotalMarket = 0;
        for ( var i=0 ; i<aaData.length ; i++ )
        {
            iTotalMarket += aaData[i][4]*1;
        }

         /* Calculate the market share for browsers on this page */
        var iPageMarket = 0;
        for ( var i=iStart ; i<iEnd ; i++ )
        {
            iPageMarket += aaData[ aiDisplay[i] ][4]*1;
        }

        /* Modify the footer row to match what we want */
        var nCells = nRow.getElementsByTagName('th');
        nCells[1].innerHTML = parseInt(iPageMarket * 100)/100 +
            '% ('+ parseInt(iTotalMarket * 100)/100 +'% total)';
     }
   } );
  } );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:08:49+00:00Added an answer on June 10, 2026 at 5:08 pm

    The function should like this

    $('#example').dataTable( {
      "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
    
        var TotalMarks = 0;
        for ( var i=0 ; i<aaData.length ; i++ )
        {
            TotalMarks += aaData[i][2]*1;
        }
    
        var nCells = nRow.getElementsByTagName('th');
        nCells[1].innerHTML = TotalMarks;
      }
    });
    

    Hope this will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the jquery datatable plugin. I have the following code that sets
I'm using jquery with datatable.editable plugin, I'm managing to add a dropdown from static
I am using the jQuery plugin called DataTables and I would like to display
I am using jQuery Datatable plugin for rendering a table as jQuery DataTable. I
I'm using the jQuery DataTables plugin to display data being returned from an AJAX
I'm using this JQuery autocomplete plugin http://www.devbridge.com/projects/autocomplete/jquery/ in my project. I followed this tutorial
I'm using this jquery plugin to build forms. In order to allow the modification
I'm currently using this jQuery validate plugin and having an issue in IE where
I'm using this jQuery inline datePicker plugin sample but I don't know how to
hai.all..can you tell me how to make table in jquery? i want using this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.