Cognito-forms – Making field calculate different answer depending on another field’s input

cognito-forms

I am trying to use Cognito Forms to make a character sheet. I have a field called STR that can have values 10-25 for example. I want to make another field that automatically shows a value based on the value in the STR field.

So if STR is 10 or 11, field 2 should display "0"
If STR is 12 or 13, field 2 should display "1"

and so on. I can't seem to figure out how to make it work.

Instructions?

Best Answer

Disclaimer: I am an engineer on the Cognito Forms team and former Pen & Paper nut

Looks like it's time for an intelligence check! rattle rattle Got it! Checking my languages, it looks like I can speak Elder Expression! This long forgotten language includes such constructs as "Ye Olde Ternary" and "Mathematical Verbisms!"

So, open ye olde scroll of Character Definition and include in this most ancient and prescient of documents an additional line item of type Calculation of the Numberic nomenclature. Append the Lay of Expressive Renown:
=Strength > 11 ? Math.Floor((Strength - 10) / 2) : 0

Failing that, the lost Ternary of Tho'mas can be used for more finite control: =(Strength = 12 Or Strength = 13) ? 1 : (Strength = 14 Or Strength = 15) ? 2 :...

But beware, along that path lies much danger and confusion!