我有一个简单的脚本,用户输入一个值,网页输出的值增加了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>
答案 0 :(得分:0)
只是做:
var amt = $("#pament").val() * 1.029;
$('#result').text(amt);
$('#amount').val(amt);