我有一個Paypal類,我想回顯表單,然後在用戶點擊付費後提交。我試過了JavaScript,但它沒有與我一起工作。立即發帖
if(isset($_SESSION['user_id']))
{
include('includes/class_paypal.php');
include 'includes/class_order.php';
include 'includes/class_user.php';
include 'includes/class_permission.php';
include('includes/adminfunctions_status.php');
$invoice = new paypal();
$order = new order($_GET['pay']);
$invoice->custom = $_GET['pay'];
$invoice->amount = $order->price;
$invoice->item_name = 'Order #'.$order->id.'';
$invoice->item_number = $order->id;
$invoice->init();
}
?>
<script type="text/javascript">
$(document).ready(myfunc() {
var frm = document.getElementById("order");
frm.submit();
}
</script>
貝寶類
var $cmd = "_xclick";
var $business = "**";
var $item_name;
var $item_number;
var $amount;
var $no_shipping = 1;
var $no_note = 1;
var $currency_code = "USD";
var $lc = 'US';
var $bn = "PP-BuyNowBF";
var $return;
var $cancel_return;
var $rm = 2;
var $notify_url;
var $custom;
function init()
{
echo '
<form id="order" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="'.$this->business.'">
<input type="hidden" name="item_name" value="'.$this->item_name.'">
<input type="hidden" name="item_number" value="'.$this->item_number.'">
<input type="hidden" name="amount" value="'.$this->amount.'">
</form>
';
}
,你可以看到我要發佈的形式初始化訂單信息後。所以當用戶轉到index.php?pay = 45(45是訂單號)時,我希望文件顯示錶單和所有內容,然後將表單發佈到PayPal。
你好,你的函數「myfunc()」永遠不會執行,因爲從來沒有調用...只是用關鍵字「function()」替換就可以工作 – sdespont 2012-07-07 07:59:11
我已經試過了它不會工作 – Othman 2012-07-07 08:02:03
你確定你沒有錯誤JS在瀏覽器的控制檯中登錄? – sdespont 2012-07-07 08:13:18