<button type="button" >total?</button>
<?php $abc= '<div id="output"></div>';
echo $abc;?>
<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_blank" runat="server">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="UK" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="Customer's First Name" />
<input type="hidden" name="last_name" value="Customer's Last Name" />
<input type="hidden" name="payer_email" value="customer@example.com" />
<input type="hidden" name="item_number" value="123456" / >
<input type="submit" value="Submit Payment"/>
</form>
<script type='text/javascript'>
$('button').click(function() {
var total = $(':checkbox:checked.case').get().reduce(function(total, checkbox) {
return total + +checkbox.value;
}, 0);
$("#output").html(total);
});
</script>
代码包含一个按钮,用于从已检查的答案中获取总和。我需要将此值传递给支付网关。
提前致谢....
答案 0 :(得分:0)
您需要另外输入表单中的金额
<input type="hidden" name="amount" value="">
然后,而不是$('button').click
注册表单提交事件,如
$(function(){
$('#paypal_form').on('submit', function(e){
var total = 'get total here';
if(!total)
{
e.preventDefault();
return false;
}
$(this).find("[name='amount']").val(total);
return true;
});
});