Assign Number Field Value based on separate Field

By: Ralph Nohe | Asked: 08/22/2024
ForumsCategory: How-toAssign Number Field Value based on separate Field
Ralph Nohe asked 4 weeks ago
I have a radio field (field ID=142) with 3 options: 1,2 and 3. I would like to show a number field below, which dynamically
  • displays 0 if option1 is selected, 
  • displays 77 if option2 is selected, 
  • displays 99 if option3 is selected.
Rather than using javascript or php, I would like to use a formula as found here like ([142] = 1) ? 0 : ([142] = 2) ? 77 : 99 that is inserted as the default value (calculation -> math) field setting of the number field. Unfortunately, this returns an error ("invalid left-hand side in assignment") and doesn't work. 
2 Answers
Rob LeVineRob LeVine answered 4 weeks ago
One issue is that you have a single equal sign rather than double, i.e, ([142] = 1) vs ([142] == 1)
Ralph Nohe answered 4 weeks ago
Hi Rob, thanks, this solves it: the double equal sign works perfectly.  Best regards, Ralph

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right