Reputation: 725
I have a input field which is populated with the numerical value selected by a donate amount button.
I need to pass the value populated or entered in the input field on to paypal ( I am using a custom button).
The code I have currently for populating the input textbox is:
<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>
The code for the paypal button is
<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>
Going by the solutions to this similar question I apparently have to provide an additional hidden field for the amount but I am not sure how to pass the value from the input text box to the amount field
Upvotes: 0
Views: 1084
Reputation: 4967
Something like this should work.
function UpdateAmount(amount, something)
{
$("#hosted_button_id").val(amount); // Or whatever the input's id is.
// Whatever you wanna do.
}
This way you can pass the amount value to the hidden input's value (inside the form perhaps), making it accessible for submitting.
If it's not what you're looking for then you'll have to make your question become more clear.
Upvotes: 1