Applying different calculations based on radio button result

91 views
Skip to first unread message

anthropaulogy

unread,
Jan 17, 2022, 7:45:14 PM1/17/22
to mementodatabase
Hi all!  Maybe a newb question but...

I have a database that tracks the work I do for my clients.  The only problem I am having is being able to calculate the various credit card processing rates, if any.  I have a radio button list with three options: 

None (when selected, no fees will be added)
Manual (when selected I need to multiply 3.5% + 0.15 to the total)
Chip (when selected, I need to multiply 2.6% + 0.10 to the total)

I understand that I need to create a Calculation field, but I am not sure how to set it up.  I am assuming I should use the Switch function, but I have no idea how to reference the above radio buttons or really how to use the Switch function in general in Memento.  

Any ideas for me?  

Bill Crews

unread,
Jan 19, 2022, 6:43:43 AM1/19/22
to anthropaulogy, mementodatabase
This Calculation field script would be hellaciously complex to write & to read! I'd like to know (not just you, but anybody, because it happens very often) why so many people use the now ancient Calculation field. It's got a few extra functions, but it's got so much of everything else that it's really, in my opinion, not wise for Memento users to keep finding & using this script rather than JavaScript. Again, this is not aimed at Paul specifically, but at everyone! If you use the databases more than a little bit, you'll end up having learned both languages.

So Javascript field. Try this:

// Values used in the script. Only if you change your fee type names will you need to modify the script below
var feesField = field("Replace this with your Radio Buttons field name";
var chipAddedFee = (2.6 / 100) * amountField + 0.10;    // Keep up to date as time goes on
var manualAddedFee = (3.5 / 100) * amountField + 0.10;     // Keep up to date as time goes on

// Fees & their types
var feeToAdd = 0;    // By default, no added fees. No need to check for "None".
if (feesField == "Chip")
    chipAddedFee;    // Returned value
else if (feesField == "Manual")
    manualAddedFee;    // Returned value

I didn't test it, so get back to us if you have an error.

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/93130e9b-93ac-4897-98db-573d612f0b91n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages