0
<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>

该代码包含一个按钮,用于从检查的答案中获取总和。我需要将此值传递给支付网关。

提前致谢....

4

1 回答 1

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;
    });
});
于 2013-06-25T05:58:33.897 回答