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.
Thread Starter
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;)
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
Thread Starter
Vyte
(@vyte)
Hi,
i have send you an mail from your contact Form:
please answer me for more informations about the login data.
My Website:
http://www.rechnungscontrol.de/test
site of the calculation form is:
http://www.rechnungscontrol.de/test/?page_id=758
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;
})();
Thread Starter
Vyte
(@vyte)
PERFECT!!
But only one think ;P
how can I automatically rounded to the 2 decimal point?
instead 76.03999999999999 >> 76.04
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.
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);
}
})();
Thanks in advance for your help!