呼喚遠方
2021-06-14 17:32:29
所以我試圖在我的 order.html 頁面上包含支付 API 結帳,但是,您必須在 HTML 文檔的頭部添加一個腳本。在腳本中,您必須將小計金額指定為數字,但我需要該值是動態的。“總計”是小計金額。我需要將小計設置為“總計”。我怎么做?<head> <script type="text/javascript"> function paymentApi() { V.init({ apikey: "", encryptionKey: "", paymentRequest: { currencyCode: "USD", subtotal: "11.00" } }); </script></head><body> <p id="sub-total"> <strong>Total</strong>: <span id="stotal"></span> </p>
2 回答

qq_花開花謝_0
TA貢獻1835條經驗 獲得超7個贊
只需更改小計即可從 html 中獲取值,如下所示
<script type="text/javascript">
function paymentApi(){
V.init( {
apikey: "",
encryptionKey: "",
paymentRequest:{
currencyCode: "USD",
subtotal: document.getElementById('stotal').innerText //Here
}
});
</script>

慕田峪7331174
TA貢獻1828條經驗 獲得超13個贊
<script type="text/javascript">
function paymentApi(){
var subtotal = parseFloat($("#stotal").text());
V.init( {
apikey: "",
encryptionKey: "",
paymentRequest:{
currencyCode: "USD",
subtotal: subtotal
}
});
</script>
添加回答
舉報
0/150
提交
取消