我希望你做得很棒。
我很难搞清楚这一点。我使用相同的代码同意条款框并提交按钮,但使用不同的按钮图像和链接。我只是为他们复制代码以同样的方式工作。 这些按钮位于同一页面上,但会将您带到不同的结帐页面。第一个代码工作正常,它会阻止用户继续检查协议框,但第二个代码即使它是相同的代码,它也没有完成工作;它让人们通过而不同意这些条款。
以下是这两个代码,您可以看到它们因超链接和按钮图像而异。
这是一个伟大的社区。我是初学者,如果这是一个业余问题,请原谅。我真的希望你们都能帮助我,我真的很感激!
非常感谢你!
<html>
<head>
<script>
function disableSubmit() {
document.getElementById("submit").disabled = true;
}
function activateButton(element) {
if(element.checked) {
document.getElementById("submit").disabled = false;
}
else {
document.getElementById("submit").disabled = true;
}
}
</script>
<center><button type="submit" id="submit" onclick="document.location.href='https://www.jvzoo.com/b/57051/250513/13';"><img src="http://i.jvzoo.com/57051/250513/13" alt="Tube Cash Blueprint (2M)" border="0" alt="Submit"/></button></center>
</head>
<center><h6> Tube Cash Blueprint Agreement</h6></center>
<body onload="disableSubmit()">
<center><input type="checkbox" name="terms" id="terms" onchange="activateButton(this)"/> Check here to indicate that you have read and agreed to the terms of the <a target="_blank" href="https://johnmichaelmarketing.com/tbc-agreement/">Tube Cash Blueprint Costumer Agreement</a> </center>
<br/><br/>
</body>
</html>
&#13;
<html>
<head>
<script>
function disableSubmit() {
document.getElementById("submit").disabled = true;
}
function activateButton(element) {
if(element.checked) {
document.getElementById("submit").disabled = false;
}
else {
document.getElementById("submit").disabled = true;
}
}
</script>
<center><button type="submit" id="submit" onclick="document.location.href='https://www.jvzoo.com/b/57051/250467/13';"><img src="http://i.jvzoo.com/57051/250467/13" alt="Tube Cash Blueprint" border="0" alt="Submit"/></button></center>
</head>
<center><h6> Tube Cash Blueprint Agreement</h6></center>
<body onload="disableSubmit()">
<center><input type="checkbox" name="terms" id="terms" onchange="activateButton(this)"/> Check here to indicate that you have read and agreed to the terms of the <a target="_blank" href="https://johnmichaelmarketing.com/tbc-agreement/">Tube Cash Blueprint Costumer Agreement</a> </center>
<br/><br/>
</body>
</html>
&#13;
答案 0 :(得分:0)
您不能对2个元素使用相同的ID。
此ID:
<button type="submit" id="submit" onclick="document.location.href='https://www.jvzoo.com/b/57051/250467/13';" disabled=""><img src="https://i.jvzoo.com/57051/250467/13" alt="Tube Cash Blueprint" border="0"></button>
与此发生冲突:
<button type="submit" id="submit" onclick="document.location.href='https://www.jvzoo.com/b/570‌​51/250513/13';"><img src="https://i.jvzoo.com/57051/250513/13" alt="Tube Cash Blueprint (2M)" border="0"></button>
只需更改ID即可。
现在你必须为每个id编写不同的函数,或者使用name
来代替它们
快速而肮脏的解决方案 - 复制功能,更改ID:
<script>
function disableSubmit1() {
document.getElementById("submit1").disabled = true;
}
function activateButton1(element) {
if(element.checked) {
document.getElementById("submit1").disabled = false;
}
else {
document.getElementById("submit1").disabled = true;
}
}
function disableSubmit2() {
document.getElementById("submit2").disabled = true;
}
function activateButton2(element) {
if(element.checked) {
document.getElementById("submit2").disabled = false;
}
else {
document.getElementById("submit2").disabled = true;
}
}
</script>
<!-- button 1 -->
<button type="submit" id="submit1" disabled="" onclick="alert('submission1')">B1</button>
<input type="checkbox" name="terms" id="terms1" onchange="activateButton1(this)" />
<!-- button 2 -->
<button type="submit" id="submit2" disabled="" onclick="alert('submission2')">B2</button>
<input type="checkbox" name="terms" id="terms2" onchange="activateButton2(this)" />
答案 1 :(得分:0)
一个文档中有两个html标记。当我使用我的firefox检查器跟踪你的代码时,你的第二个代码就像第一个代码的srciptt。我看到并复制的内容:
<br><br>
<script type="text/javascript">
<html>
<head>
<script>
function disableSubmit() {
document.getElementById("submit").disabled = true;
}
function activateButton(element) {
if(element.checked) {
document.getElementById("submit").disabled = false;
}
else {
document.getElementById("submit").disabled = true;
}
}
</script>
如果您希望代码工作从第二个代码中删除<html><head><script>
。