我有一个输入字段,该字段由捐赠金额按钮选择的数值填充。
我需要将在输入字段中填充或输入的值传递到贝宝(我使用的是自定义按钮)。
我目前用于填充输入文本框的代码是:
<div class="border-all-background">
<div class="border-all-background">
<h2><span>SELECT AN AMOUNT</span> </h2>
<div align="center">
<a href="#" class="simple-button " onclick="return UpdateAmount(25,'other_amount')">$25</a>
<a href="#" class="simple-button " onclick="return UpdateAmount(50,'other_amount')">$50</a>
<a href="#" class="simple-button " onclick="return UpdateAmount(75,'other_amount')">$75</a>
<a href="#" class="simple-button " onclick="return UpdateAmount(100,'other_amount')">$100</a>
<a href="#" class="simple-button " onclick="return UpdateAmount('other','other_amount')">Other</a>
<br />
</div>
<br />
<div style="padding-left:75px;" >
<span><h4> Your Donation <span>* </span> $
<input name="other_amount" type="tel" class="textField validate min:1" id="other_amount" size="12" value="" data-charactercount="" data-charactercount-limit="6"></h4></span>
</div>
贝宝按钮的代码是
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXX">
<input type="image" src="https://dl.dropboxusercontent.com/u/106279316/paypal%20button/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
根据这个类似问题的解决方案,我显然必须为金额提供一个额外的隐藏字段,但我不确定如何将值从输入文本框传递到金额字段
这样的东西应该可以工作。
function UpdateAmount(amount, something)
{
$("#hosted_button_id").val(amount); // Or whatever the input's id is.
// Whatever you wanna do.
}
通过这种方式,您可以将amount值传递给隐藏输入的值(可能在表单中),使其可供提交。
如果这不是你想要的,那么你必须让你的问题变得更加清楚。