Im customizing a payment gateway solution using php and jquery. Before i pass the data(ie. customer address, tele, amount of purchase, etc.), I want to deduct 2.9% from the purchase/product amount.(which would be my personal service fee) and then pass the remaining balance to the payment gateway for processing. How would i do this using PHP?
var $adjustedamount;
var $mypercentage = 0.029;
function computemypercentage($original_price){
$adjustedamount = ($original_price += ($original_price * $mypercentage));
return $adjustedamount;
}
document.getElementById("trueamount").innerHTML= computemypercentage(29.99);
As I stated in the comments already, please ensure ANY calculations about money are done on the server side. JavaScript is great for providing a better user experience, but not for critical business logic.
The reason for this is that it is simply too easy to modify those values. Pull up any modern browser and open the developer tools. You can change form values and JavaScript at will, making anything coming from the client untrustworthy by default.
As for assigning the value to some element… your code should work fine: http://jsfiddle.net/yPC3K/