# sum to table row data when I search in my Dashboard searchbar

**URL:** <https://forum.djangoproject.com/t/sum-to-table-row-data-when-i-search-in-my-dashboard-searchbar/13535>\
**Category:** Using Django\
**Created:** [May 5, 2022, 11:56am UTC](https://forum.djangoproject.com/t/sum-to-table-row-data-when-i-search-in-my-dashboard-searchbar/13535 "2022-05-05T11:56:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajsmack](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ajsmack/32/8096_2.png) [@ajsmack](https://forum.djangoproject.com/u/ajsmack)\
**Post date:** [May 5, 2022, 11:56am UTC](https://forum.djangoproject.com/t/sum-to-table-row-data-when-i-search-in-my-dashboard-searchbar/13535/1 "2022-05-05T11:56:57Z")

</div>

I want to sum the duration of all rows displayed in the table after searching the student’s name as per the image if I search ’ Abhi ’ it returns me 2 rows I want to sum of these 2 rows using javascript on the right-hand side as you see I fetch duration print in the browser console instead of returning me 2 row’s of duration it returns me all rows.

```auto
 <script>
<script type="text/javascript">
    function mySearchFunction() {
        $('#total').remove();
        $('#mybutton').remove();
        var input, filter, table, tr, td, i, txtValue;
        input = document.getElementById("myInput");
        filter = input.value.toUpperCase();
        table = document.getElementById("myTable");
        tr = table.getElementsByTagName("tr");
        // teach_dur = tr.getElementsByTagName("td");
        // console.log(teach_dur)
        for (i = 0; i < tr.length; i++) {
            td = tr[i].getElementsByTagName("td")[0];
            // console.log(td)
            if (td) {
                txtValue = td.textContent || td.innerText;
                // console.log(txtValue)
                if (txtValue.toUpperCase().indexOf(filter) > -1) {
                    tr[i].style.display = "";
                    // console.log(x)
                } else {
                    tr[i].style.display = "none";
                }
            }
        }

        var table = $("table tbody");
        table.find('tr').each(function (i, el) {
        var $tds = $(this).find('td'),
            Quantity = $tds.eq(3).text();
            console.log(Quantity)
</script>

```

 ![Capture4](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/e/e2777d71e02c57df354cd77bdf4c167ba29e4e39.jpeg)
