0

我有一个简单的脚本,用户输入一个值,网页输出添加 2.9% 的值。到目前为止,一切都很好。我正在努力将该值传递给同一页面上的 PayPal(输入名称“金额”)表单。尝试了几件事,但到目前为止没有运气。

     <script src="http://code.jquery.com/jquery-latest.min.js"
                type="text/javascript"></script>  
        <label>payment amount:</label><input name="payment" id="payment" type="text" />
                   <br />
                  Above payment + convenience fee: $ <span id="result"></span>



    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">

    <input type="hidden" name="business" value="test@test.com">
    <input type="hidden" name="item_name" value="example description">
    <input type="hidden" name="item_number" value="1">
<!--NEED HELP HERE W/ AMOUNT:--> <input type="text" name="amount" id="amount">
    <input type="hidden" name="no_shipping" value="1">
    <input type="hidden" name="return" value="http://www.yoursite.com/returnpage.php">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="US">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but02.gif" border="0" name="submit" alt="Make your payments with PayPal. It is free, secure, effective.">
    <img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1">
    </form>


    <script>

        $(document).ready(function(){
        $('#payment').keyup(function(){
            $('#result').text($('#payment').val() * 1.029)

        });

        });
    </script>
4

1 回答 1

0

做就是了:

var amt = $("#pament").val() * 1.029;
$('#result').text(amt);
$('#amount').val(amt);
于 2013-01-20T17:20:26.773 回答