我有一张表格要求他们购买的小部件数量,最终目标是相应地改变paypal成本。 如何调整代码以获得所需的结果?
var amountOfWidgets = document.getElementById('firstBox').value;
document.getElementById("price").innerHTML = "<input type="hidden" name="amount" value=amountOfWidgets>"
}
</script>
<div id="myCheckout">
</br>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="Example@gmail.com">
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="item_number" value="1">
<input type="hidden" id="price" name="amount" value="6.99">
<input type="hidden" name="no_shipping" value="0">
答案 0 :(得分:0)
给表单命名。 PayPal通常将其命名为_xclick
。
使用Javascript:
document._xclick.amount.value = price;
答案 1 :(得分:0)
<input type="text" id="usd" size="20" name="usd" onchange="workaround()"
function workaround() {
var amount = document.getElementById("usd").value;
paypal.Button.render({
rest of paypal code...
...
amount: { total: amount , currency: 'USD' }
...
}
}
会做的伎俩...