If formtext is hidden, don't count its value

Hello everyone

I'm making a sort of calculator with fields that I activate or not. Which works perfectly.

But to do it well, I want if I hide a text box containing a sum, it is not included in the result.

Is it possible ?

Thank you all

Number of prices ? {formmenu: default=0; 1; 2; name=prices}

{if: prices = "1" OR prices = "2"}{formtext: name=pricedollars1; default=50}${endif}
{if: prices = "2"}{formtext: name=pricedollars2; default=50}${endif}

Total {=pricedollars1 + pricedollars2}$

Not sure I fully understand this, but it sounds like you want something like:

Number of prices ? {formmenu: default=0; 1; 2; name=prices}

{if: prices = "1" OR prices = "2"}{formtext: name=pricedollars1; default=50}${endif}
{if: prices = "2"}{formtext: name=pricedollars2; default=50}$

Total {=pricedollars1 + pricedollars2}${endif}

Not that :slightly_smiling_face:

If i select one price, the total take the first text box.
If i select the second price, total count the first and second text box.

but if I change my mind, i choose only one text box, i do not want box number 2 where I entered an amount to be counted

I hope that it's clearer.

Is this what you're looking for?

@Frenchy_Devs

Number of prices ? {formmenu: default=0; 1; 2; name=prices}

{if: prices = "1" OR prices = "2"}{formtext: name=pricedollars1; default=50}${endif}
{if: prices = "2"}{formtext: name=pricedollars2; default=50}${endif}

{counted1=pricedollars1 if prices="1" or prices="2" else 0}
{counted2=pricedollars2 if prices="2" else 0}
Total {=counted1 + counted2}$

1 Like

Ho yeaaaaaaaaaaaaaaaa :sunglasses:

Perfect

2 Likes

WOW! I had no idea you could nest IF statements within a variable. #gamechanging!

1 Like

Glad you like it :slightly_smiling_face: This is the ternary operator listed in this section: Text Blaze | Formula Reference It's an expression, so you can use this in many places by putting it inside parentheses - (<expression>).