title: jquery auto calculate total [laravel]
body: <p>hye, i am planning to create a form where the user checked the checkbox and enter the value, the total will be auto-calculated.</p>
  <p>i'm using jquery,laravel 7. i noticed that total is not appear tho..
  below is jquery</p>
  <pre><code>//calculation    
         //calculation    
          var total  = 0,
              values = [];
          
          $('input[type=checkbox], input[type=number]').each(function() {
             $(this).change(function () {
                  if( $ (this).is(':checked') &amp;&amp; $ (this).val().length != 0) {
                      values.push($(this).val().attr('quantitys'));
                      total += parseFloat($(this).val()) * parseFloat(attr('quantitys'));
                  }
             });
          });
  
          $(&quot;#total&quot;).text(total);
          
  </code></pre>
  <p>below is the html</p>
  <pre><code>  @foreach ($services as $s)
                      &lt;tr&gt;
                          &lt;td&gt;&lt;div class=&quot;custom-control custom-checkbox&quot;&gt;
                             &lt;input type=&quot;checkbox&quot; name=&quot;serviceName&quot; class=&quot;custom-control-input&quot; id=&quot;customCheck{{$loop-&gt;index}}&quot; value=&quot;{{$s -&gt; servicePrice}}&quot; &gt;
                              &lt;label class=&quot;custom-control-label&quot; for=&quot;customCheck{{$loop-&gt;index}}&quot;&gt;{{$s -&gt; serviceName}} {{$s -&gt; servicePrice}}&lt;/label&gt;
                          &lt;/div&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;input type=&quot;number&quot;  class=&quot;form-control&quot; id=&quot;quantitys&quot; name=&quot;quantity&quot; &quot; placeholder=&quot;weight/measurements&quot;  &gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  @endforeach
  </code></pre>
  <p>here is the snippet of the form, beside the service is the price</p>
  <p><a href="https://i.stack.imgur.com/Lt2au.png" rel="nofollow noreferrer">form</a></p>