dongxi2163 2019-08-08 07:20
浏览 57

如何使用laravel或javascript或jquery在数组迭代中添加数字之和?

adding the sum of numbers in array iterationtried using javascript but didnt succeed

@extends('layouts.master')@section('content')
<!-- Content Wrapper. Contains page content -->

<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <div class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6"> </div>
        <!-- /.col -->
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="#">Home</a></li>
            <li class="breadcrumb-item active">Timesheets</li>
          </ol>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div>
    <!-- /.container-fluid -->
  </div>
  <!-- /.content-header -->
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header">
              <h5 class="card-title">Timesheets</h5>
              <div class="card-tools"> <button type="button" class="btn btn-tool" data-widget="collapse"> <i class="fa fa-minus"></i> </button> </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body"> @include('layouts._messages')
              <div class="row">
                <div class="col-md-12">
                  <table class="table table-striped" id="timesheets-table">
                    <thead>
                      <tr>
                        <th>Id</th>
                        <th>Date</th>
                        <th>Staff Name</th>
                        <th>Department</th>
                        <th> <a href="#" data-toggle="tooltip" title="{{@$tact1->projectname}}"> {{@$tact1->projectcode}} </a> </th>
                        <th> <a href="#" data-toggle="tooltip" title="{{@$tact2->projectname1}}"> {{@$tact2->projectcode1}} </a> </th>
                        <th> <a href="#" data-toggle="tooltip" title="{{@$tact3->projectname2}}"> {{@$tact3->projectcode2}} </a> </th>
                        <th> <a href="#" data-toggle="tooltip" title="{{@$tact4->projectname3}}"> {{@$tact4->projectcode3}} </a> </th>
                        <th>Total Hours</th>
                        <th> <input type="checkbox" name="acs" value="Approve All" style="display:none">Approve All
                          <th> <input type="button" onclick='selectAll()' value="Approve All" class="bg-success text-white" /> <input type="button" onclick='UnSelectAll()' value="Unselect All" class="bg-danger" /> </th>
                        </th>
                      </tr>
                    </thead>
                    <tbody> @foreach($timesheets as $timesheet)
                      <tr>
                        <td> {{$timesheet->id}} </td>
                        <td> {{Carbon\Carbon::parse(@$timesheet->date)->format('D d-m-Y')}} </td>
                        <td> {{@$timesheet->first_name}} {{@$timesheet->last_name}} </td>
                        <td> {{@$timesheet->unitname}} ({{@$timesheet->cname}}) </td>
                        <td class="proj" name="acs"> <strong>{{@$timesheet->hour}} HRS</strong> </td>
                        <td class="proj" name="acs"> @if(@$timesheet->hour1 == 0) - @else <strong>{{@$timesheet->hour1}} HRS</strong> @endif </td>
                        <td class="proj" name="acs"> @if(@$timesheet->hour2 == 0) - @else <strong>{{@$timesheet->hour2}} HRS</strong> @endif </td>
                        <td class="proj" name="acs"> @if(@$timesheet->hour3 == 0) - @else <strong>{{@$timesheet->hour3}} HRS</strong> @endif </td>
                        <td class="proj bg-success text-white"> <strong class="text-lg"> {{@$timesheet->total_hours}} </strong> </td>
                        <td> <input type="checkbox" name="acs"> Approve </td>
                      </tr>
                      <?php
    ?> @endforeach
                        <div class="mx-auto"> {{ $timesheets -> links() }} </div>
                    </tbody>
                    <tfoot>
                      <tr>
                        <td class="bg-danger"><strong>Total:</strong></td>
                      </tr>
                    </tfoot>
                  </table> <input type="button" value="Get Selected" onclick="GetSelected()" /> <br / </div> @endsection
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)