我正在尝试通过单击提交两个表单。我正在尝试打开一个新窗口,以便用户可以使用贝宝付款。
以下是它的工作原理:
有一个表格可以预约。
如果用户选择使用 paypal 单选按钮付款,并且表单已提交,则新的 paypal 结帐表单将添加到原始表单之外的页面。像这样:
if ($paypal_radio.eq(1).attr('checked')) {
//make paypal buttons
$('#content').append('<div id="paypal_form_container">');
var $paypal_form = $('#paypal_form_container');
//make the form template
var paypal_form_template ='\
<form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post" id="paypal_form"> \
<input type="hidden" name="cmd" value="_xclick"> \
<input type="hidden" name="business" value="email@email.com"> \
<input type="hidden" name="lc" value="US"> \
<input type="hidden" name="item_name" value="whatever"> \
<input type="hidden" name="currency_code" value="USD"> \
<input type="hidden" name="lc" value="US"> \
<input type="hidden" name="rm" value="1"> \
<input type="hidden" name="Cleaning Service" value="whatever"> \
<input type="hidden" name="amount" value="'+totalValue+'"> \
</form> \
';
//add the form to the page
$paypal_form.html(paypal_form_template);
//submit both forms
$('#paypal_form').submit();
$(this).parents("form").submit();
}
我希望提交贝宝表格并在新窗口中打开(注意目标空白),然后将预订表格提交到当前页面。
我的问题是,只有最后一个提交值被发送,无论是最后一个,都没有关系。
处理此问题并一键发送两种表单的最佳方法是什么?