【问题标题】:Dynamic Price Change with Paypal API?Paypal API 的动态价格变化?
【发布时间】:2017-03-10 19:54:05
【问题描述】:

我有一个表格询问他们想要购买的小部件数量,最终目标是相应地更改贝宝费用。 如何调整我的代码以获得预期的结果?

    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">

【问题讨论】:

  • 我知道很久了,但是……你解决了吗?

标签: javascript html dynamic paypal innerhtml


【解决方案1】:

给表格一个名字。 PayPal 通常将其命名为_xclick

Javascript:

document._xclick.amount.value = price;

【讨论】:

    【解决方案2】:
    <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' }
          ...
       }
    }
    

    会成功的......

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多