jquery - Javascript make subtraction in real time -


i working on pos project, , need subtraction in real-time tip after have manually add amount of money client gave. not sure going wrong code, little please.

<div class="sidebar-category">     <div class="category-content" style="padding: 8px">         <div class="row">             <div class="col-sm-6">                 <input id="client_paid" type="text" placeholder="paguar" class="form-control" >                 <br>                 <input  id="change" type="text" placeholder="resto" class="form-control change">             </div>              <div class="col-sm-6">                 <h6 class="text-semibold text-right no-margin-top">totali: <span id = "all-products-subtotal"> {{session::get('all_products_subtotal') ? number_format(session::get('all_products_subtotal'),2,",","."):'0'}} </span> </h6>                 <ul class="list list-unstyled text-right">                 status: &nbsp;                 <a href="#" class="label bg-success-400 dropdown-toggle" data-toggle="dropdown">online</a>                 </ul>             </div>         </div>     </div> </div> 

and script:

<script>     $("#client_paid").keyup(function(){         var client_paid = this.val();         var total ={{session::get('all_products_subtotal') ? number_format(session::get('all_products_subtotal'),2,",","."):'0'}};          if(client_paid >= total){             var change = client_paid - total;             $("#change").val(change);         }     }); </script>                        

here illustrating picture

check function firing properly, using $(document).ready? might want try replacing this.val() $(this).val()


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -