• Resolved etuno98

    (@etuno98)


    Hello.
    I’m creating a discount code calculator for a client’s website. The company offers coupons for restaurants, and we have an example menu with some prices so you can choose a meal and simulate how much you would pay if you use the company’s coupons.

    So, I need a way to create a dropdown menu with each meal having its own price. Example: Ribs: $10, Sushi $7, so on and so forth. What I am having trouble with is using the ‘value’ field by the meal’s name and use this value in an equation.

    What exactly is the syntax for using the ‘value’ field in an equation?

    • This topic was modified 4 years, 7 months ago by etuno98.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @etuno98

    The process is really simple. In the DropDown fields, the choices have associated two boxes, for the choice’s text, and its value. As the choice’s text, enter the text you want, for example, Sushi $7, but for its value, enter the number only, without currency symbol, in this case, 7. The equations use the values of the choices selected, and not their texts.

    Best regards.

    Thread Starter etuno98

    (@etuno98)

    Oh, okay! I see
    I’ll use the fieldname1 (for example) and it’ll extract the value I assign
    But I have 3 other forms I use, and need to use in the same outcome

    Example: If you choose Pizza in the first menu, you’ll choose Cheese pizza in field14
    If you choose Mexican food, you then choose tacos in field15

    CHeese pizza and tacos have different values, but when they choose Cheese pizza, it’s field14, and tacos are in field15. Was that clear?

    How do I use that in formula? Would that take javascript or an advanced equation?

    • This reply was modified 4 years, 7 months ago by etuno98.
    • This reply was modified 4 years, 7 months ago by etuno98.
    Plugin Author codepeople

    (@codepeople)

    Hello @etuno98

    I’m sorry, I need to check your form in action to understand your project’s flow, because I don’t understand the reason why you have implemented the process with multiple forms.

    Best regards.

    Thread Starter etuno98

    (@etuno98)

    It goes like this:
    Field1 is Choose a type of food (Pizza, Mexican, Chinese)
    Field 2 is for Pizzas (cheese, mushrooms, peperoni)
    Field 3 is for Mexican (tacos, quesadillas)
    And field 4 is for Chinese (pork, shrimp)

    When you choose the type of food in the first menu, the next dropdown menu will correspond to your choice (you’ll only see cheese, mushrooms and peperoni when you choose pizza)

    I didn’t know if there is a better way to do this, but then I assigned a price to each flavor, and I want to calculate the the discount on the flavor in the next field

    But this makes me need to have multiple fields when people select different types of food

    Not sure if that was clear

    • This reply was modified 4 years, 7 months ago by etuno98.
    Plugin Author codepeople

    (@codepeople)

    Hello @etuno98

    In this case, all fields are inserted into the same form, the fieldname1 would be a DropDown field with three choices: Pizza, Mexican, Chinese

    The fieldname2 would be a DropDown field with the choices: cheese, mushrooms, and pepperoni, furthermore, this field should be defined as dependent on the first choice in the fieldname1

    More information about dependencies, reading the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    The fieldname3 would be a DropDown field with the choices: tacos, and quesadillas, and will be defined as dependent on the second choice in the fieldname1

    And finally, the fieldname4 would be another DropDown field with the choices: pork, and shrimp, and it is defined as dependent on the third choice in the fieldname1

    Only one of the fields fieldname2, fieldname3, and fieldname4 will be active at once because they are defined as dependent on the choices of the same field. Furthermore, the values of the inactive dependent fields are zero. So, the sum of these fields won’t be affected if two of them are inactive. You can use as part the equation:

    (fieldname2+fieldname3+fieldname4)

    Because only the price of the active DropDown field affects it.

    Best regards.

    Thread Starter etuno98

    (@etuno98)

    Alright this solved it!! Thanks so much! I didn’t know the inactive fields would have 0 as value because I thought they would still be counting their values as they are… still there, in a way.

    I was able to calculate everything properly now, thanks to your help

    Again, thank you very much!

    • This reply was modified 4 years, 7 months ago by etuno98.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I use the dropdown menu ‘value’ in an equation?’ is closed to new replies.