Sum column in table

I have a jquery bootgrid. I am trying to display the sum of the "Time" in the footer: ID = #totalTime. I can't get this code to work.

----------Javascript
            // dynamically find columns positions
            var indexTime = -1;
            $(bootGrid).find('th').each(function (e) {
                if ($(this).attr('data-column-id') == 'time') {
                    indexTime = e;
                }
            });
            var totalTime = 0.0;
            $(bootGrid).find('tbody tr').each(function () {
                var time = 0.0;
                // loop through rows
                $(this).find('td').each(function (i) {
                    if (i == indexTime) {
                        time = parseFloat($(this).text());
                        alert(time);
                    }
                });
                totalTime += time;
            });
            $('#totalTime').text(totalTime.toFixed(2));

Open in new window


---BootGrid
            <table class="table table-condensed table-hover table-striped" id="grid-data">
                <thead>
                    <tr class="grid-header-nav">
                        <th data-column-id="time_id" data-visible="false">Time ID</th>
                        <th data-column-id="time">Time</th>
                    </tr>
                </thead>
                <tbody>
                    @{
                        foreach (TimeInfo timeinfo in Model.TimeInfos)
                        {
                            <tr>
                                <td>@timeinfo.Time_ID</td>
                                <td>@timeinfo.Time</td>
                            </tr>
                        }
                    }
                </tbody>
                <tfoot>
                    <tr>
                        <td>Total Hours</td>
                        <td id="#totalTime"></td>
                    </tr>

                </tfoot>
            </table>

Open in new window

Stacey FontenotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
do right click on the table.grid, choose view source and post it here.
Stacey FontenotAuthor Commented:
I was just able to update the code and was able to get the summation working. I just can't get it to display the sum to id:total. totalTime has a value.

  $('#total').text(totalTime.toFixed(2));
Zakaria AcharkiAnalyst DeveloperCommented:
I guess the problem comes from the id of the element :

<td id="#totalTime"></td>

Open in new window


Should be :

<td id="totalTime"></td>

Open in new window


Note the # sign must be removed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.