Skip to content

Instantly share code, notes, and snippets.

@wildanm
Created August 10, 2012 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wildanm/3311107 to your computer and use it in GitHub Desktop.
Save wildanm/3311107 to your computer and use it in GitHub Desktop.
$("[name='sales_items[qty][]'],[name='sales_items[price][]'],[name='sales_items[discount][]']").unbind("keyup").bind("keyup", function(){
var qty = $(this).parent().parent().find("[name='sales_items[qty][]']").autoNumericGet({aSep: '.', aDec: ',',aPad:true,vMax:100000000000000000}) ;
var price = $(this).parent().parent().find("[name='sales_items[price][]']").autoNumericGet({aSep: '.', aDec: ',',aPad:true,vMax:100000000000000000}) ;
var disc = $(this).parent().parent().find("[name='sales_items[discount][]']").autoNumericGet({aSep: '.', aDec: ',',aPad:true,vMax:100000000000000000}) ;
var total = qty*price
var minus = (disc/100)*total ;
total = total-minus ;
$(this).parent().parent().find("[name='sales_items[total][]']").autoNumericSet(total,{aSep: '.', aDec: ',',aPad:true,vMax:100000000000000000});
}) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment