gpt4 book ai didi

jquery - 表单无法在 IE 中正确提交

转载 作者:行者123 更新时间:2023-12-01 01:53:17 25 4
gpt4 key购买 nike

除了 Internet Explorer 之外,我的简单捐赠表单都能正确提交。我确信这与change()和focus()或blur()的问题有关,但到目前为止我的数百次尝试都失败了。我尝试使用 .click() 而不是这篇文章中提到的change():Getting jQuery to recognise .change() in IE (和其他地方),但我无法让它工作! ...所以我可能忽略了一些简单的事情。

以下是页面链接:http://www.wsda.org/donate

HTML 表单:

<form id="donationForm" method="post" action="https://wsda.foxycart.com/cart.php" class="foxycart">
<input type="hidden" id="name" name="name" value="Donation" />
<input type="hidden" id="price" name="price" value="10" />
<div class="row">
<label for="price_select">How much would you like to donate?</label>
<select id="price_select" name="price_select">
<option value="10">$10</option>
<option value="20">$20</option>
<option value="50">$50</option>
<option value="100">$100</option>
<option value="300">$300</option>
<option value="0">Other</option>
</select>
</div>
<div class="row" id="custom_amount">
<label for="price_input">Please enter an amount: $</label>
<input type="text" id="price_input" name="price_select" value="" />
</div>
<input type="submit" id="DonateBtn" value="Submit Donation »" />
</form>

JQUERY:

// donation form
$("#custom_amount").hide();
$("#price_select").change(function(){
if ($("#price_select").val() == "0") {
$("#custom_amount").show();
} else {
$("#custom_amount").hide();
}
$("#price").val($("#price_select").val());
});

$("#price_input").change(function(){
$("#price").val($("#price_input").val());
});

最佳答案

使用这篇文章给出的答案之一:Getting jQuery to recognise .change() in IE - 我将脚本修改为以下内容,现在效果很好!!

有效的新脚本!:

// donation form
$("#custom_amount").hide();
$("#price_select").change(function(){
if ($("#price_select").val() == "0") {
$("#custom_amount").show();
} else {
$("#custom_amount").hide();
}
$("#price").val($("#price_select").val());
});

if ($.browser.msie) {
$("#price_input").click(function() {
this.blur();
this.focus();
});
};

$("#price_input").change(function(){
$("#price").val($("#price_input").val());
});

关于jquery - 表单无法在 IE 中正确提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3011186/

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