<script language="javascript" type="text/javascript">
function changeDonation(){
return document.getElementById("quantity").value;
}
</script>
This function is associated with
<input type="number" id="quantity" min="<?php echo $minimum_donation; ?>"
max="100" onchange="setDonation()">
and
<a href="<?php echo $paypal_redirect;?>"
onclick="location.href=this.href+''+changeDonation();return false;">
I want to modify my changeDonation() so that +changeDonation() is always at least the amount of $minimum_donation. Right now, its possible for users to not change the value of “quantity” and proceed with the donation value of $0.
Here is what I tried:
<script>
if (changeDonation()<3) {
function changeDonation(){
return 3;
}
}
else {
return changeDonation()
}
</script>
But if I do that, changeDonation is always 3. Ideally, I want 3 to be replaced by the $minimum_variable (php variable), and have it functional. I am a complete javascript noob so please forgive me for my dumbness!
I believe something like this is more what you are looking for.
Thanks to Tom and Maël Nison for the improvements