I am trying to calculate a formula based on the selection in a dropdown. In the blend percentages dropdown, the user can select anything from 100% to 25-25-25-25% blend percentage. According to which blend percentage the user selects, it changes how I need to calculate the formula. Each blend percentage has a certain variable that I need to times by either .50, .33, .25 etc.
I am trying to figure out a way to have a hidden input box that takes the blend percentage selected by the user, and input a certain value based on their selection. For example, if the user selects “75%-25%”, the input field will show .75. I will then use that input field to run my calculation off of.
You’re on the right track. Have an input element with “this element is visible on page load” unchecked. And use conditions to set different initial content values based on the dropdown selection.
For example: when dropdown’s value is “50%-50%” > initial content = .50
Just remember that the dropdown value in the conditions need to be written exactly as you have written it in the dropdown element (case-sensitive). So create a different condition for each dropdown value.
If you want to consolidate this a little and/or if these blend percentages are saved to your database under a Blend Percentage type, you could also just add another field to store the multiplier value. Then you wouldn’t need conditions. Just set the default initial content to “Dropdown value’s multiplier”
@romanmg
That’s perfect!! Thank you. I was able to get the formula to calculate correctly using states as well.
Do you know how I can round a number? I see the :round to option, but not sure what to put after it. The number I am currently getting from my formula is quite long, more than 10 decimal points. I want it to be a whole number.