的總價格,我有這部分代碼:計數選擇複選框
<form action="{{ URL::action('server-shop-post') }}" method="post" id="cart">
<table class="table table-responsive">
<thead>
<tr><th>Check</th><th>Item</th><th>Pixel Points <span class="fa fa-cubes"></span></th></tr>
</thead>
<tbody>
@foreach($shopItems as $shopItem)
<tr>
<td>
@if(!in_array($shopItem -> id, $userPurchases))
<input form="cart" name="cart[]" value="{{ $shopItem -> id }}" type="checkbox">
@else
<span class="glyphicon glyphicon-ok"></span>
@endif
</td>
<td>
{{ $shopItem -> name }}
</td>
<td>
{{ $shopItem -> cost }}
</td>
</tr>
@endforeach
<tr><td colspan="2">You have <span class="fa fa-cubes"></span> {{ Auth::user() -> pixel_points }}</td><td>Total cost: 200</td></tr>
</tbody>
</table><input type="submit">
</form>
這裏做的事情,是創建一個完整的商店物品表,並允許人們檢查複選框「添加到購物籃」。然後,價格也會顯示在與複選框相同的行中。 我的目標是讓用戶檢查一個項目,以及總成本更新。 如何將所有值一起添加到勾選框中?
看看這個問題。我在那裏提出了一個答案:[http://stackoverflow.com/questions/26702514/how-do-i-get-my-checkbox-values-and-option-values-to-add-up-and-enter-the -sum入/ 26702588 noredirect = 1#comment42018025_26702588] [1] [1]:http://stackoverflow.com/questions/26702514/how-do-i-get-my-checkbox- value-and-option-values-to-add-up-and-enter-the-sum-in/26702588?noredirect = 1#comment42018025_26702588 – Tom 2014-11-03 21:05:33