Zero is not working
-
I am having an issue with the calculated field. On the balloon payment, I want that if anyone adds a number that will calculate, or if they do not add the number or leave it as zero, it will also calculate and give the result.
But not able to achieve the result https://prnt.sc/U1k8Cd0T-rRr
Here is the link of that form https://www.olgarsauto.co.za/?cff-form=8
Let me please because I have to fix the problem.
The page I need help with: [log in to see the link]
-
Hello @bulbuljessore
Thank you very much for using our plugin.
I’m sorry, I don’t understand your question about the equations because the screenshot provided is about dependency rules.
Could you please be more specific?
Best regards.
Ok so if you check the calculator link there is a balloon payment. And I do not want to make it mandatory.
So for example If I do not put any value on that balloon payment it will calculate the monthly and total payment or if I put any value on that balloon payment this will also calculate the value base on that percentage in the balloon payment section.
but currently is not calculating anything if I leave the balloon payment option zero.
I hope that makes seance. Looking forward to hearing from you.
Hello @bulbuljessore
Your “Monthly Payment” equation is:
prec((fieldname2*fieldname7/fieldname14/1200*pow(1+fieldname7/fieldname14/1200,fieldname8)-fieldname6*fieldname7/fieldname14/1200)/(pow(1+fieldname7/fieldname14/1200,fieldname8)-1),2)You are using fieldname14 as the divisor. In mathematics, the division by zero generates an error. I don’t know the result you want to display when the fieldname14 is empty or zero (mathematically, both situations are considered as zero). You should use conditional statements in the equation to separate both cases:
(function(){ if(fieldname14) { return prec((fieldname2*fieldname7/fieldname14/1200*pow(1+fieldname7/fieldname14/1200,fieldname8)-fieldname6*fieldname7/fieldname14/1200)/(pow(1+fieldname7/fieldname14/1200,fieldname8)-1),2); } else return 0; })()Best regards.
Thanks, I appreciate it but a little bit confused that where you want me to use these conditional statements.
I mean if you tell me which section I have to put in that will be more helpful for me to fix the problem.
Hello @bulbuljessore
The code I sent you previously corresponds to the equation in the “Monthly Payment” field. You should select the field in the forms builder, and enter the equation through its “Set equation” attribute.
Best regards.
Thanks for your help but that did not change anything. I have already updated the code as you said. You can check the result that I send before the link.
All I need is if someone leaves the balloon payment as zero it will calculate the monthly and total payment or if someone add any value to the balloon payment it will calculate the monthly and total payment based on all field including the balloon payment.
Hello @bulbuljessore
The equation is being evaluated, but in this case, the result is zero.
To be clear, in mathematics you cannot divide by zero. So, your original equation is valid only for cases where fieldname14 is different from zero.
prec((fieldname2*fieldname7/fieldname14/1200*pow(1+fieldname7/fieldname14/1200,fieldname8)-fieldname6*fieldname7/fieldname14/1200)/(pow(1+fieldname7/fieldname14/1200,fieldname8)-1),2)Please, describe the equation you want to evaluate when fieldname14 is zero or empty.
Best regards.
Ok so when the fieldname14 is zero or empty it will calculate from the value-added into fieldname6 & fieldname7
And when fieldname14 is not zero or empty then it will calculate using fieldname6, fieldname7 & fieldname14
I hope that makes sense
Best regards.
Hello @bulbuljessore
So, if you want to implement the same equation but without the fieldname14 field. It would be similar to:
(function(){ if(fieldname14) { return prec((fieldname2*fieldname7/fieldname14/1200*pow(1+fieldname7/fieldname14/1200,fieldname8)-fieldname6*fieldname7/fieldname14/1200)/(pow(1+fieldname7/fieldname14/1200,fieldname8)-1),2); } else { return prec((fieldname2*fieldname7/1200*pow(1+fieldname7/1200,fieldname8)-fieldname6*fieldname7/1200)/(pow(1+fieldname7/1200,fieldname8)-1),2); } })()Please, note I’m not implementing your equation. I’m teaching you to use the
ifconditional statements.Best regards.
Hi there
Thanks for the code it’s working when fieldname14 is zero but if I put something on fieldname14 it’s not calculating.
So I am not sure if I can explain it to you or not but on the car calculation some people want to know how much it will be monthly and total payment with balloon payment and some people do not want to know how much it will be monthly and total payment without a balloon payment.
So it has to work both ways. Please let me know if this is possible with this plugin or not.
Best regards.
Hello @bulbuljessore
I’m not checking your mathematics, but the equation is being evaluated. Please, watch the video by visiting the following link:
https://resources.developers4web.com/cff/tmp/2022/08/04/video-form_o.mp4
Best regards.
Hello again
Sorry about that I notice the result on an incognito window and I appreciate that you help me to fix it.
Best regards.
Hello again
I noticed that on balloon payment if I put 1% is not changing any value on monthly and total payment would please help me fix the issue.
Please note that if I put 2 on balloon payment it changing the value.
Looking forward…
Hello @bulbuljessore
Yes, that’s correct. In mathematics A/1 = A
So, if you enter the number 1 the result does not vary.
Please, note you have selected the “Number” option for the “Number format” attribute in the fieldname14. For the plugin, it is a basic number. If you want the plugin to treat the value as a percentage, you should select the “Percent” option.
If you configure the number format as percent, and you enter the number 1 as the field’s value, the plugin will use it in the equations as 0.01
Best regards.
The topic ‘Zero is not working’ is closed to new replies.