我已經完成了一個帶有自動計算腳本的表單,但我似乎無法將金額的值傳遞給PayPal。將HTML形式的javascript valiables傳遞到PayPal
他們是一種將java變量轉換爲php變量或其他技巧的方法嗎?
我一直在googleing超過2小時,我的眼睛在他們的插座旋轉。 :)
<html>
<head>
<script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script>
function $_(IDS) { return document.getElementById(IDS); }
function setPrice() {
var A = parseFloat($_('A').value*10.);
var B = parseFloat($_('B').value*10.);
var C = parseFloat($_('C').value*10.);
var D = parseFloat($_('D').value*10.);
var E = parseFloat($_('E').value*10.);
var F = parseFloat($_('F').value*10.);
var G = parseFloat($_('A').value*1.);
var H = parseFloat($_('B').value*1.);
var I = parseFloat($_('C').value*1.);
var J = parseFloat($_('D').value*1.);
var K = parseFloat($_('E').value*1.);
var L = parseFloat($_('F').value*1.);
var kids = (G+H+I+J+K+L);
if (kids==1){
var result = (+A+B+C+D+E+F).toFixed(2);
}
if (kids==2){
var result = (+A+B+C+D+E+F-5).toFixed(2);
}
if (kids>2){
var result = (+A+B+C+D+E+F-6).toFixed(2);
}
if (kids==1){
var tax = ((+A+B+C+D+E+F)*1.13).toFixed(2);
}
if (kids==2){
var tax = ((+A+B+C+D+E+F-5)*1.13).toFixed(2);
}
if (kids>2){
var tax = ((+A+B+C+D+E+F-6)*1.13).toFixed(2);
}
$_('kids1').value = kids;
$_('total1').value = result;
$_('amount').value = tax;
};
</script>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="[email protected]" />
<input type="hidden" name="item_name" value="2014/2015 Registration" />
<input type="hidden" name="currency_code" value="CAD" />
<input type="hidden" name="return" value="http://www.mysite.com/payments/?payment=success" />
<input type="hidden" name="cancel_return" value="http://www.mysite.com/payments/?payment=cancelled" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHostedGuest" />
<input type="text" size="1" maxlength="3" id="A" onChange="setPrice()">
<input type="text" size="1" maxlength="3" id="B" onChange="setPrice()">
<input type="text" size="1" maxlength="3" id="C" onChange="setPrice()">
<input type="text" size="1" maxlength="3" id="D" onChange="setPrice()">
<input type="text" size="1" maxlength="3" id="E" onChange="setPrice()">
<input type="text" size="1" maxlength="3" id="F" onChange="setPrice()">
<br>
Order total = $<input type="text" id="total1" readonly /><br>
With tax total = $<input type="text" id="amount" readonly /><br>
Total Kids = <input type="text" id="kids1" readonly /><br>
<br>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" name="submit" alt="PayPal . The safer, easier way to pay online." />
</form>
輸出,其中是PHP代碼?哪個變量通過? –