對不起。 我試圖讓這個過程不起作用。 我有這樣的代碼:使用Ajax顯示php的百分比
function paypalFees($sub_total, $round_fee) {
// Set Fee Rate Variables
$fee_percent = '8'; // Paypal's percentage rate per transaction (3.4% in UK)
$fee_cash = '0.00'; // Paypal's set cash amount per transaction (£0.20 in UK)
// Calculate Fees
$paypal_fee = ((($sub_total/100) * $fee_percent) + $fee_cash);
if ($round_fee == true) {
$paypal_fee = ceil($paypal_fee);
}
// Calculate Grand Total
$grand_total = ($sub_total + $paypal_fee);
// Tidy Up Numbers
$sub_total = number_format($sub_total, 2, '.', ',');
$paypal_fee = number_format($paypal_fee, 2, '.', ',');
$grand_total = number_format($grand_total, 2, '.', ',');
// Return Array
return array('grand_total'=>$grand_total, 'paypal_fee'=>$paypal_fee, 'sub_total'=>$sub_total);
看到的結果我已經把建立一個數字:
$receipt = paypalFees('150.00', false);
結果由
<h2>Your Receipt</h2>
<li>Sub-Total: £<?php print $receipt['sub_total']; ?></li>
<li>Booking Fee: £<?php print $receipt['paypal_fee']; ?></li>
<li>TOTAL: £<?php print $receipt['grand_total']; ?></li>
所示看到的結果我有刷新頁面。
如何在沒有刷新頁面的情況下使用ajax來執行此過程? 一個例子: Sum HTML Textbox Values using jQuery/JavaScript
查看網絡套接字,例如http://pusher.com – Utkanos 2014-10-30 13:12:45
您既可以使用AJAX,也可以使用Javascript進行所有計算。 – Barmar 2014-10-30 13:13:25