# WordPress.org

## Calculated Fields Form[resolved] If function from excel to CFF (5 posts)

1. asidance
Member
Posted 2 years ago #

I just made this formula, but doesn't work, could someone please identify the mistake im making? Thank you to anyone with future responses.

(function(){
IF(fieldname12="Semi-Gloss Paper",0.32,
IF(fieldname12="Matte Paper",0.38,
IF(fieldname12="White BOPP",0.6,
IF(fieldname12="Clear BOPP",0.57,
IF(fieldname12="Top Coated Direct Thermal Paper",0.45,
IF(fieldname12="Thermal Transfer Paper",0.35))))))
})();

2. codepeople
Member
Plugin Author

Posted 2 years ago #

Hi,

I recommend you to read any tutorial of javascript. The complex equations in the Calculated Field are made using javascript, so it is recommended some basic knowledge of javasctipt to create complex equations.

For example in the equation posted, I can't understand what you pretend calculate.

3. asidance
Member
Posted 2 years ago #

let me explain the formula a bit more.

I want the outcome of a dropdown option to change a field's value.

so if they choose semi-gloss paper the field would be 0.32

I'm not too great with javascript, if you could get me started on how i would do this, I would Greatly Appreciate it.

4. codepeople
Member
Plugin Author

Posted 2 years ago #

The equation should be like follow:

(function(){
if(fieldname12=="Semi-Gloss Paper") return 0.32;
if(fieldname12=="Matte Paper") return 0.38;
if(fieldname12=="White BOPP") return 0.6;
if(fieldname12=="Clear BOPP") return 0.57;
if(fieldname12=="Top Coated Direct Thermal Paper") return 0.45;
if(fieldname12=="Thermal Transfer Paper") return 0.35;
})();

5. asidance
Member
Posted 2 years ago #

THANK YOU VERY MUCH.
Just recently started doing codecademy on javascript.

Also... where do these functions go? and how do i utilize them in a form?

This topic has been closed to new replies.

• Calculated Fields Form
• Reviews

No tags yet.