Adding amounts based on checkbox status

Hi,

I’m having a problem with calculating a cost (Main Rate) alongside some optional extras (Checkbox1,Rate1).

On my ‘booking’ page, I have a Main Price and then checkboxes (Checkbox1) for a number of optional extras. These extras each then have an associated rate (Rate1) which disappears when unchecked.

When a buyer wants to purchase from the seller, they can elect some of these optional extras. I want to present a total cost (all on one page) that updates when the checkbox is selected/unselected.

I want to do a Total Price calculation that essentially is “Main Rate + (if Checkbox1 is yes) Rate1 + (if Checkbox2 is yes) Rate2” etc.

I have the Rates set up as disabled inputs on this page, so I can reference the numbers, but I can’t seem to find how to get the total price to change based on the status of the checkboxes.

I tried making the input visible/invisible based on the checkbox status, but the calc still applies the rate even if invisible.

I am using MathsExpressCalc plugin (just as an fyi).

Obviously this nut has been cracked before, so I’m eager for any suggestions on a fix (or why there’s another way that’s just better).

Thanks

i use the instantcalculator plugin. just my preference

database design
project
-----price…number
-----(optional) list of extra rates … extra rate (list)

extra rate
----price…number
----include…yes/no
-----project ref…project

design--------------------
group for project
-----data source, do search for projects, first project
-----input for main rate for project
----calculator inside project group
repeating group inside that project group
----- data source, do a search for rates - or - parent groups projects extra rate list
----input and checkbox inside each cell
----checkbox is directly linked to cur cells extra rate “include”

calculator expression:
parent projects rate + arbitraytext:converted to number
arbitrary text is “do a search for extra rates, include = yes, project = parent groups project” sum

(or do the projects extra rate list and filter for include is yes)

if you want to get fancy, calculator is hidden on page load, and visible when the project total price is not the project price + the extra rates

This topic was automatically closed after 70 days. New replies are no longer allowed.