I have a donation script at this moment where the user inputs the donation amount on the Paypal website. The problem with this is that some people donate $0.30 which equates to $0 after Paypal fees. I want to put first check the amount donated using an input on my website and then send off the amount to the Paypal website where they can continue to enter their credit card information and what not. How do I do this? Do I have to change to another mode? or am I supposed to send the amount to Paypal and then they'll know how it's handled?
A:
Generally, yes, you'd determine the amount before passing the user over to PayPal.
Amber
2010-05-01 20:01:44
How do I pass it to Paypal?
Doug
2010-05-01 22:05:36
Which Paypal API are you using to direct the user over to Paypal in the first place?
Amber
2010-05-02 01:14:40
A:
You can add a simple check using javascript on the page.
Start with the "donate" button disabled.
<form name="myform>
...
<input type="submit" name="submit" disabled="disabled"/>
In the edit field where the user enters their donation amount, add onblur and onkeyup handlers that call an update() function.
<input type="text" name="donation" value="15.00"
onkeyup="update()" onblur="update()"/>
Add a javascript update() function that then reads the entered text, and enables the "donate" button if the value entered is valid, and disables it if it is invalid.
<script type="text/javascript">
function update()
{
if ((float) document.myform.donation.value < 5.00)
document.myform.submit.disabled = true;
else
document.myform.submit.disabled = false;
}
</script>
(or thereabouts :-)
Jason Williams
2010-05-01 20:29:16
You might just as well give users a pre-defined list of amounts. I've seen that working pretty well for lots of uses.
admp
2010-05-01 20:42:53