[英]Action after a form is submitted
Is there a way in which after a form is submitted you can change the value of a field? 有没有一种方法可以在提交表单后更改字段的值?
I have a form where a select
field is disabled, in order to post the form I enable it but immediately after I want it to be set back to disabled is true
. 我有一个其中禁用了select
字段的表单,为了发布该表单,我启用了它,但是在我希望将其重新设置为disabled之后,它才是true
。 This is my code: 这是我的代码:
$("Form").submit(function() {
$("#done", this).prop("disabled", false);
});
I cannot test it right now but try this approach: 我现在无法对其进行测试,但是可以尝试以下方法:
$('Form').submit(function (e) {
e.preventDefault(); // don't submit multiple times
$('Form.select').prop('disabled', true); // Enable the select
this.submit(); // use the native submit method
$('Form.select').prop('disabled', false); // Disable the select
});
Let me know how this works out. 让我知道如何解决。
OR 要么
$('Form').submit(function (e) {
e.preventDefault(); // don't submit multiple times
$('Form.select').prop('disabled', true); // Enable the select
$.post('action.php', $('Form').serialize()); // AJAX submit
$('Form.select').prop('disabled', false); // Disable the select
});
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.