【发布时间】:2012-01-27 18:51:48
【问题描述】:
我有一个带有多个提交按钮的表单。我只想在按下其中任何一个后禁用它们,并且一切正常,直到我在 .submit() JQuery 处理程序中“禁用”它们,在这种情况下,表单不再显示与表单一起发送按钮名称/值信息.如何禁用按钮但仍提交按钮名称/值,以便确定按下了哪个按钮?
表格
<form action="myaction" method="post" name="sendgift" id="sendgift" >
....input, etc ....
<input type="submit" name="_action_go" value="Looks great! Do it" id="sendgiftbtn" />
<input type="submit" name="_action_index" value="I need to make changes" id="gobackbtn" />
</form>
JS:
<script type="text/javascript">
$("#sendgift").submit(function() {
//if I remove these two lines, everything works
$("#sendgiftbtn").attr('disabled', 'disabled');
$("#gobackbtn").attr('disabled', 'disabled');
console.log("disable buttons called");
return true;
});
</script>
【问题讨论】: