Support » Plugin: Calculated Fields Form » if calculation

• Resolved mhecht2013

(@mhecht2013)

Hi,
I have problem with a formula :
fieldname 3 is a number
fieldname 4 is a number
fieldname 5 is a number
fieldname 6 is a number
fieldname 9 is a multiple choice (4 choices)with text value

The outcome of the formula I would like dépends of the choice. Then I wrote :

``````(function() {
if ( fieldname9="100% douches") {return (fieldname3*50+fieldname4*98+fieldname5*132+fieldname6*177)
}
else if ( fieldname9="80% douches") {return (fieldname3*54+fieldname4*105+fieldname5*141+fieldname6*191)
}
else if ( fieldname9="50% douches") {return (fieldname3*59+fieldname4*115+fieldname5*134+fieldname6*211)
}
else ( fieldname9="20% douches") {return (fieldname3*64+fieldname4*125+fieldname5*169+fieldname6*236)
})()``````

It does not work. Could you help ?
Best regards.

http://wordpress.org/plugins/calculated-fields-form/

Viewing 6 replies - 1 through 6 (of 6 total)
• Plugin Author codepeople

(@codepeople)

Hi,

Without modify the fields values, try the following equation:

(function() {
if ( fieldname9=100) {return (fieldname3*50+fieldname4*98+fieldname5*132+fieldname6*177);
}
else if ( fieldname9=80) {return (fieldname3*54+fieldname4*105+fieldname5*141+fieldname6*191);
}
else if ( fieldname9=50) {return (fieldname3*59+fieldname4*115+fieldname5*134+fieldname6*211);
}
else ( fieldname9=20) {return (fieldname3*64+fieldname4*125+fieldname5*169+fieldname6*236);
})();

If the options values start with a number, the “Calculated Fields Form” extracts the number, and use it in the equation.

Best regards.

mhecht2013

(@mhecht2013)

But it did not work !
Anything else ?
Thank you so much.

Plugin Author codepeople

(@codepeople)

Hi,

Could you send me the link to the webpage for checking the issue, please?

If you prefer, may send the link through our support page in:

http://wordpress.dwbooster.com/support

Best regards.

mhecht2013

(@mhecht2013)

Plugin Author codepeople

(@codepeople)

Hi,

After checking the equation format exhaustively, I’ve detected multiple errors. The correct equation format is below:

``````(function() {
if ( fieldname9==100) {return (fieldname3*50+fieldname4*98+fieldname5*132+fieldname6*177);}
else if ( fieldname9==80) {return (fieldname3*54+fieldname4*105+fieldname5*141+fieldname6*191);}
else if ( fieldname9==50) {return (fieldname3*59+fieldname4*115+fieldname5*134+fieldname6*211);}
else if ( fieldname9==20) {return (fieldname3*64+fieldname4*125+fieldname5*169+fieldname6*236);}
})();``````

[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

mhecht2013

(@mhecht2013)

It works.
Thanks a lot for your support.
Best ragards

Viewing 6 replies - 1 through 6 (of 6 total)
• The topic ‘if calculation’ is closed to new replies.