所以我试图在我的 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
提交
取消