【发布时间】:2021-07-30 19:53:04
【问题描述】:
https://jsfiddle.net/Popo74123/q92jh1p0/474/
这是我拥有的代码。现在贝宝按钮正在提交表单。它现在没有连接到贝宝。基本上我想要的是当他们到达表格的最后一步时,下一个按钮变成贝宝按钮。
<div style="overflow:auto;">
<div style="float:right;">
<button type="button" class="form" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
<button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
</div>
js
function nextPrev(n) {
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form... :
if (currentTab >= x.length) {
//...the form gets submitted:
document.getElementById("regForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
这是我认为可以修复的另一个功能。
function showTab(n) {
// This function will display the specified tab of the form ...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
// ... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
// ... and run a function that displays the correct step indicator:
fixStepIndicator(n)
}
我不能只编辑innerHTML = "submit" 的 if 语句,而不是 paypal 按钮吗?我不知道如何引用贝宝按钮。
【问题讨论】:
-
我在最后一页上没有看到“下一步”按钮。您指的是“提交”按钮吗?
-
是的,我只是说下一个按钮,因为我有 Js 将下一个按钮变成提交。
标签: javascript html paypal-buttons