Support » Plugin: Calculated Fields Form » need help for a calculation.

• Resolved Vyte

(@vyte)

English:
hi,
I need help with a calculation.
It is this.

If a number is entered in box A to box B automating the following directions:

If the number is less than 750 in panel B, only 35 displayed.
If the number is greater than 750 to 35 + 2% of the number entered are displayed.
If the number is greater than 1500 to 45 + 2% of the number entered are displayed.

What should I enter?

Thank you;)

German:
hi,
ich brauche hilfe bei einer Kalkulation.
Es geht um folgendes.

Wenn im Feld A eine Zahl eingeben wird soll Feld B folgendes automatisierend berechnen:

Ist die Zahl kleiner als 750 soll im Feld B nur 35 angezeigt werden.
Ist die Zahl größer als 750 sollen 35 + 2% der eingegebenen Zahl angezeigt werden.
Ist die Zahl größer als 1500 sollen 45 + 2% der eingebenen Zahl angezeigt werden.

Was muss ich eingeben?

Vielen Dank 😉

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

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

(@codepeople)

Hi,

I’ll call the field A, fieldname1, and the field B, fieldname2 (because it is the name format of fields in the plugin), the fieldname2 will be the Calculated Field, so the equation in this case would be:

(function(){
if(fieldname1 < 750) return 35;
if(fieldname1 >= 750 and fieldname1 < 1500) return 35+fieldname1*0.02;
if(fieldname1 >= 1500) return 45+fieldname1*0.02;
})();

Note: In your form the field A can coincide with a different fieldname, so in this case you should replace fieldname1 in the equation by the correct one.

Vyte

(@vyte)

Hey,
Unfortunately, the calculation does not work. I see no number in the calculation field: (
Nevertheless thank you but maybe you see the error still;)

of course I have adapted the field names;)

Plugin Author codepeople

(@codepeople)

Hi,

Could you send me the link to your webpage through our support page for checking the form’s structure, please?

Our contact page:

http://wordpress.dwbooster.com/support

Vyte

(@vyte)

Hi,

i have send you an mail from your contact Form:

My Website:
http://www.rechnungscontrol.de/test
site of the calculation form is:
http://www.rechnungscontrol.de/test/?page_id=758

Plugin Author codepeople

(@codepeople)

Hi,

I’m sorry, my fault the correct equation is below:

(function(){
if(fieldname1 < 750) return 35;
if(fieldname1 >= 750 && fieldname1 < 1500) return 35+fieldname1*0.02;
if(fieldname1 >= 1500) return 45+fieldname1*0.02;
})();

Vyte

(@vyte)

PERFECT!!

But only one think ;P
how can I automatically rounded to the 2 decimal point?
instead 76.03999999999999 >> 76.04

Plugin Author codepeople

(@codepeople)

Hi,

It is simple, exists the operation “prec”, for set precision of equation’s result. The number of decimal digits is passed as the second parameter. So, the equation would be:

(function(){
if(fieldname1 < 750) return 35;
if(fieldname1 >= 750 && fieldname1 < 1500) return prec(35+fieldname1*0.02,2);
if(fieldname1 >= 1500) return prec(45+fieldname1*0.02,2);
})();

Best regards.

brookevmf

(@brookevmf)

Hi there,

Great plugin! I too am having a problem with a formula and have read all the issues I can find to solve it but it’s not working.

I need a formula for a form with 3 fields. I need the results of a calculation to depend on two of those fields.

So if fieldname81 is below a certain number AND fieldname83 (a dropdown) is 1, give X calculation.
Else if fieldname81 is between two numbers AND fieldname83 (a dropdown) 1, give Y calculation.
Else if fieldname81 is above a certain number AND fieldname83 (a dropdown) 1, give Z calculation.

The whole thing needs to repeat again but with fieldname83 being 2 and being 3. It’s getting complicated… 🙁

Here’s what I wrote:

``````(funtion() {
if (fieldname81 < 448) {return
((fieldname84*fieldname81*0.1818)/1000);}
else if (fieldname81 >= 448 && fieldname81 < 1127 && fieldname82 == 1) {return ((fieldname84*fieldname81*0.09887)/1000);}
else if (fieldname81 >= 448 && fieldname81 < 1127 && fieldname82 == 2) {return
((fieldname84*fieldname81*0.1483 )/1000);}
else if (fieldname81 >= 448 && fieldname81 < 1127 && fieldname82 == 3) {return
((fieldname84*fieldname81*0.2038 )/1000);}
else if (fieldname81 >= 1127 && fieldname82 == 1) {return
((fieldname84*fieldname81*0.08667)/1000);}
else if (fieldname81 >= 1127 && fieldname82 == 2) {return
((fieldname84*fieldname81*0.2513 )/1000);}
else if (fieldname81 >= 1127 && fieldname82 == 3) {return
((fieldname84*fieldname81*0.3467 )/1000);
}
})();``````