php - javascript calculate 10% discount on sub total -


how implement calculating 10% discount base on sub total in js?. here code.

<!-- sub total --> function calculategrandtotal() {     var grandtotal = 0;     $('table tbody tr td:nth-child(4) input').each(function (index) {                                 grandtotal += parseint($(this).val());     });     $('#sub_total').val(grandtotal); } 

it this:

function calculategrandtotal() {                             var grandtotal = 0;                             $('table tbody tr td:nth-child(4) input').each(function (index) {                                 grandtotal += parseint($(this).val());                             });                             $('#sub_total').val(grandtotal);                             $('#discount').val(calculatediscount(grandtotal));  }  //separate function calculate discount function calculatediscount(amt){    if(!nan(amt)){       return amt*0.1;//10% disc    }else return 0; } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -