daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Jan 16th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TABLE HEADERS
  2.  
  3.      @{ foreach (var item in Model.Tblstsabit)
  4.       {
  5.  
  6.       <tr style="padding:50px;">
  7.        <td style="text-align:center">
  8.         @Html.DisplayFor(c => item.StokKodu)
  9.        </td>
  10.        <td style="text-align:center">
  11.        @Html.DisplayFor(c => item.StokAdi)
  12.        </td>
  13.        <td style="text-align:center">
  14.        @Html.DisplayFor(c => item.SatisFiat1, new { @class = "unitprc" })
  15.         @*for this part I tried <input type="text" class="unitprc"> it works in jsfiddle.net but not in VS*@
  16.        </td>
  17.        <td style="text-align:center;">
  18.        <input type="text" class="qtt" />
  19.        </td>
  20.         <td style="text-align:center;">
  21.         <input type="number" max="100" class="col-9" />
  22.         </td>
  23.          <td style="text-align:center;">
  24.           <input type="number" max="100" class="col-9" />
  25.        </td>
  26.         <td style="text-align:center;">
  27.        <input type="text" readonly value="0.00" class="sum" />
  28.        </td>
  29.        <td style="text-align:center">
  30.         <button type="submit" class="btn btn-danger" asp-action="Remove" asp-route-stokkodu="@item.StokKodu">
  31.         <img src="~/resimler/garbage.png" />
  32.        </button>
  33.          </td>
  34.        </tr>
  35.    }
  36. }
  37.    
  38. <div class="col-4">
  39. <label>Total Sum</label>
  40. <input id="gsum" value="0.00" readonly />
  41. </div>
  42.    
  43. <script>
  44.     $(".tbl").on("change keyup keydown paste propertychange bind mouseover", function () {
  45.         calculateSum();
  46.     });
  47.  
  48.     // function    
  49.     function calculateSum() {
  50.         var sum = 0;
  51.         $(".sum").each(function () {
  52.             if (!isNaN(this.value) && this.value.length != 0) {
  53.  
  54.     var quantity = $(this).closest("tr").find("input.qtt:text").val();
  55.     var valor = $(this).closest("tr").find("input.unitprc:text").val();
  56.  
  57.     var subTot = (quantity * valor);
  58.  
  59.     $(this).val(subTot.toFixed(2));
  60.  
  61.     sum += parseFloat(subTot.toFixed(2));
  62.             }
  63.         });
  64.         $('#gsum').val(sum.toFixed(2));
  65.  
  66.     }
  67. </script>
  68.    
  69. <td style="text-align:center" class = "unitprc">
  70.    @Html.DisplayFor(c => item.SatisFiat1)
  71.  </td>
  72.    
  73. $("input.qtt:text").on("change paste keyup" ,function () {
  74.             calculateSum();
  75.         });
  76.  
  77.         // function
  78.         function calculateSum() {
  79.             var sum = 0;
  80.             $(".sum").each(function () {
  81.                 if (!isNaN(this.value) && this.value.length != 0) {
  82.  
  83.                     var quantity = $(this).closest("tr").find("input.qtt:text").val();
  84.                     var valor = $(this).closest("tr").find(".unitprc").html();
  85.  
  86.                     var subTot = (quantity * valor);
  87.  
  88.                     $(this).val(subTot.toFixed(2));
  89.  
  90.                     sum += parseFloat(subTot.toFixed(2));
  91.                 }
  92.             });
  93.             $('#gsum').val(sum.toFixed(2));
  94.  
  95.         }
  96.    
  97. var quantity = parseFloat($(this).closest("tr").find("input.qtt:text").val());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top