<div class="row "> <table class="table table-bordered table-hover table-striped col-md-11 text-center "> <tr> <th>Row</th> <th>Image</th> <th>ProductTitle and Details</th> <th>Size</th> <th>Price</th> <th>Discount</th> <th>Count</th> <th>Sum</th> <th>SumWithDiscount</th> </tr> @{ int RowCount = 1; } @foreach (var item in Model.IEProduct) { <tr> <td>@RowCount</td> <td><img src="/img/logo.png" width="100" /></td> <td><a href="/Product/ShowProduct/@item.ProductID" target="_blank">@item.ProductTitle</a></td> <td>@item.Size</td> <td value="@item.ProductPrice" class="productPrice"> @if (item.ProductPrice.HasValue) { @item.ProductPrice.Value.ToString("0,#") } </td> @if(item.Discounts.Any(d => d.ProductID == item.ProductID)) { <td class="productDiscount" value="@item.Discounts.First(d => d.ProductID == item.ProductID).DiscountPercent" > @item.Discounts.First(d => d.ProductID == item.ProductID).DiscountPercent </td> } else { <td class="productDiscount" value="0" > 0 </td> } @*@Html.Action("shoppingCart","Product",new {productid=item.ProductID })*@ <td> <input type="number" min="0" class="input" style="width: 70px;"/> </td> <td class="Sum"> </td> <td class="SumWithDiscount"> </td> </tr> RowCount++; } </table> </div> </div> </div> @section Script { <script> function MySum() { var percent = $('#productDiscount').attr("value"); var price = $('#productPrice').attr("value"); var productcount = document.getElementById('count').value; var sum = productcount * price; var sumwithdiscount = sum - ((sum * percent) / 100); $('#Sum').html(sum); $('#SumWithDiscount').html(sumwithdiscount); } $(".input").onKeyUp(function () { var percent = $('.productDiscount').attr("value"); var price = $('.productPrice').attr("value"); var productcount = $(this).value; var sum = productcount * price; var sumwithdiscount = sum - ((sum * percent) / 100); $(".Sum").each(function () { $(this).html(sum); }); $(".SumWithDiscount").each(function() { $(this).html(sumwithdiscount); }); }); </script> }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)