• Resolved ABDesignStationery1979

    (@abdesignstationery1979)


    I need to know if possible if the Calculated Fields Form is adequate enough to produce the following calculations. I have a Meal prep website installed for some customer and the need a page where a customer can go on select from 3 different drop down menus (Protein, Carbs, Greens) and then it calculate the numbers given in each field to give a calorie Macro counter total. For example the drop down boxes they choose;
    Chicken 120g, Broccoli 75g, Pasta 100g

    I need the form to be able to calculate the 3 numeric values up and give a total.

    Is this possible at all?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    Yes of course, that’s possible.

    Each choice in a DropDown field has associated two values: the text to display in the form, and the value to use in the equations. So, assuming you insert three DropDown fields in the form (fieldname1, fieldname2, and fieldname3) for proteins, carbs, and greens respectively, where the fields’ choices include, as their values, the calories per product and as their texts the names of the products.

    The equation associated to the calculated field would be as simple as:

    fieldname1+fieldname2+fieldname3

    and that’s all.
    Best regards.

    Thread Starter ABDesignStationery1979

    (@abdesignstationery1979)

    Hi mate
    That is all sorted and worked fine with those equations. One last solution I need to my problem for this customer is where I have Proteins / Carbs / Greens and currently gives the total calories of I need this to give the total macros for each of the selected items from the customers visiting the website. The current formula in the background where I put the numeric value in for the product I need this to be able to give me 4 calculations for example;
    Chicken Breast
    Green Beans
    Boiled Rice
    Calories 100 Protein 100 Carbs 100 Fats 100
    At the minute this only gives me the Calories and only adds up 1 of the numbers put in the numeric field value.
    Your help is appreciated very much and the page in question is https://premier-nutrition.uk/calories-calculator/ to visit.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    The solution in your case would be different, you should create a javascript object where the products names are its properties (because javascript does not support associative arrays), and each property would be a new object with the calories and macros corresponding to the product. And then, instead to sum directly the calories entered as the values of the choices, you should get the property in the object, based on the option selected, to calculate the sum of calories, and macros.

    If you need additional help implementing your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Query’ is closed to new replies.