0
我想做一个窗体,其中有两个提交按钮。这是表格。如何使用带多个提交按钮的JQuery提交表单?
<form method="POST" id="addCreditsForm">
<div class="row">
<div class="col s12 m10 offset-m1 l10 offset-l1 input-field">
<input type="number" name="amount" id="amount" required/>
<label for="amount">Amount</label>
</div>
<div class="col s12">
<p id="addWithPaypal" style="margin-top:5px;margin-bottom:5px;" class="btn blue">Pay with Paypal</p>
<p id="addWithInstamojo" style="margin-top:5px;margin-bottom:5px;" class="btn blue">Pay with Instamojo</p>
</div>
</div>
</form>
我试图用JQuery的做到这一点。这里是JQuery代码。
$(document).ready(function(){
$("#addWithPaypal").click(function(){
$("#addCreditsForm").attr('action'."paypal/add/credits");
$("#addCreditsForm").submit();
});
$("#addWithInstamojo").click(function(){
$("#addCreditsForm").attr('action'."instamojo/add/credits");
$("#addCreditsForm").submit();
});
});
但是当我点击任何负责在事件上调用JQuery函数的元素时,JQuery不起作用。我尝试在两个按钮的单击事件上都触发警报,但它不工作!
我不知道什么是错的。请帮助我!
是保持
.
,这就是解决方案!我怎么会这么笨,哈哈! –你可以接受答案,如果它帮助你@AdarshSojitra –