gpt4 book ai didi

JavaScript:一页上有两个 "I agree to terms checkboxes"

转载 作者:行者123 更新时间:2023-11-28 16:31:11 24 4
gpt4 key购买 nike

我有两项协议(protocol),用户必须通过选中两个不同的框(每个协议(protocol) 1 个)来“同意”,然后才能继续进入购物车。如果没有选中任何框,则两个警报都会通知他们“同意”,然后再一次继续处理 1 个警报,以及单独处理每个警报。但是,当两者都被选中时,“提交按钮”将不会提交并继续。我怎样才能让以下内容发挥作用?

两者均未选中?警报 1

#1 未选中?警报2

#2 未选中?警报3

请帮忙!

<script language="Javascript">
function check_agree (form) {
if (form.agree.checked) {
}
else { alert('You must agree to the application agreement terms before continuing.'); }
}
form.submitButton.disabled = true;
function check_agree_2 (form) {
if (form.agree_2.checked) {
}
else { alert('You must agree to both!'); }
}
form.submit()
</script>

html

<form action='http://webisite.com' method='post' onSubmit="return false;">
<p>
<span style="text-align: center">
<input type ="checkbox" name="agree" value="anything">

<b>I Agree To And Understand The Charges That Will Be Processed To My Credit Card</b></span></p>
<p>&nbsp;</p>
<input type ="checkbox" name="agree_2" value="anything">

<b>I Have Read And Agree To The Member Agreement/Terms And Conditions </b>
<p>&nbsp;</p>
<span style="text-align: center">
<input type="submit" name="submitButton" onClick="check_agree(this.form);check_agree_2(this.form)" value="Continue To Shopping Cart">

</form>

最佳答案

替换 check_agree,删除 check_agree_2,并更改提交按钮。

function check_agree(form) {
if (form.agree.checked && form.agree_2.checked) {
return true;
} else if(!form.agree.checked) {
alert('You must agree to the application agreement terms before continuing.');
} else if(!form.agree_2.checked) {
alert('You must allow us to charge your credit card.');
}
return false;
}

html

<input type="submit" name="submitButton" onClick="check_agree(this.form)" value="Continue To Shopping Cart">

关于JavaScript:一页上有两个 "I agree to terms checkboxes",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5925377/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com