javascript - Count a total price of selected checkboxes -
i have section of code:
<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 $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>
what does, creates table total of shop items , allows people check checkboxes 'add basket'. cost displayed in same row check box. aiming have user check item, , total cost update along it. how can add together values tick boxes checked?
iterating through list items might costly if huge list.. bind "onchange" event handler every checkbox.
$( ".acommonclass" ).change(function() { //check if checked or unchecked. //based on that, add together or sub value total });
javascript php laravel
No comments:
Post a Comment