I'm working with a set of JavaScripts that process these forms. I'm not as proficient with javascript as I am other things and I'm getting stuck on something that has to be simple.
If you take a look at this page on my test server:
http://sandbox.angelleye.com/client-sites/healthy-years/recc_donation.phpYou'll see it's a basic form with a check box that you need to check in order to acknowledge the recurring donation payment. The submit button is just a graphic linked to a javascript function to process the form.
I've set the checked value of the check box to 1 and I'm trying to add logic to the javascript function so that if the value of the box is NOT 1 it returns an error. The problem I'm running into is that because this isn't actually being submitted by a form the value 1 is being passed for that check box into the javascript function whether it's actually checked or not. Therefore, the following...
var confirmAgreement = document.getElementById('r
ecurring_a
cknowledge
').value;
if (confirmAgreement != 1) {
alert("Please acknowledge your recurring donation by checking the box.");
return;
}
never gets displayed becuase the box always equals 1 no matter what.
Then another problem is that we have another donation page that is NOT recurring and therefore doesn't have a check box to acknowledge the recurring payment. When I have that logic included in the processDonation() function and try and submit the form that doesn't include that check box at all nothing happens. I don't get a warning about the box not being checked (which I actually expected even though the box doesn't exist...it doesn't equal 1) and it doesn't move on to the rest of the function either. If I remove that logic and then submit the non-recurring form it does indeed go through the processing as it should.
So, any information on how I can fix these problems would be greatly appreciated. It seems like the easy solution would be to make it an actual form, however, all of the processing is already wrapped into javascript processing so I'd rather just figure out how to fix this little fluke than re-write everything.
Start Free Trial