I have created a donation form and would like to add a tick box which adds 3% of the donated amount to the total to cover card fees (I want to make it optional for the donor) - I tried the answer below but couldnt get it to work Thanks
Using chatgpt That sounds like a great idea to help cover card fees! To achieve this with RSForm, you'll need to use a bit of JavaScript to calculate the additional 3% fee when the tick box is selected. Here’s a step-by-step guide to add the tick box and implement the calculation:
Add the Tick Box Field:
Go to your RSForm Pro form management.
Add a new Checkbox field where users can opt to cover the 3% card fee. For example:
Field Label: Cover 3% Card Fee
Name: cover_fee
Value: 1
Add a JavaScript Code to Your Form:
Go to the Form Properties tab.
Scroll down to "Scripts" and click on "Custom Code."
In the "JavaScript" section, add the following code:
javascript RSFormPro.addEvent(window, 'load', function() { var donationField = document.getElementById('donation'); // Replace 'donation' with the ID of your donation amount field var coverFeeCheckbox = document.getElementById('cover_fee'); // Replace 'cover_fee' with the ID of your checkbox var totalField = document.getElementById('total'); // Replace 'total' with the ID of your total amount field
function calculateTotal() {
var donationAmount = parseFloat(donationField.value) || 0;
var fee = coverFeeCheckbox.checked ? donationAmount * 0.03 : 0;
totalField.value = (donationAmount + fee).toFixed(2);
}
RSFormPro.addEvent(donationField, 'keyup', calculateTotal);
RSFormPro.addEvent(coverFeeCheckbox, 'change', calculateTotal);
}); Adjust Your Fields and IDs:
Make sure to replace donation, cover_fee, and total with the actual IDs of your donation amount, tick box, and total amount fields in your form.
This script will automatically update the total amount based on whether the checkbox is selected and the donation amount entered. If the donor opts to cover the fee, the total amount will include an additional 3% of the donation amount.