I’m a complete noob so this might not work but I have a function that is structured like this and it works for me. Not sure if the opening parenthesis makes a difference in this plugin but I pulled this syntax directly from their documentation.
(function(){
if(fieldname10 == 12)
return prec(fieldname1*1.4,2);
if(fieldname10 == 24 )
return prec(fieldname1*1.6,2);
if(fieldname10 == 36)
return prec(fieldname1*1.8,2);
})();
-
This reply was modified 8 years, 1 month ago by
phixate.
Thread Starter
denisa
(@elenadenisa)
Hi @phixate,
Thank you for your post, but mine is a for loop, not a conditional if statement,a nd it will not work. I’m not a pro also, so I’m sure that somewhere I miss something.
Thank you anyway for trying to help me.
Well, I tried! Hope you get it resolved.
Thread Starter
denisa
(@elenadenisa)
I’ve fixed the code, but I have a very simple issue now, and to tired to be able to get it work. I’ll open a new thread
Hello ,
There are some errors in your code, actually the equation’s structure should be:
(function(){
})()
To allow it be evaluated immediately.
Second, there are many variables defined globally, and some semicolon symbols that were not included, and much more important, there is required a “return” instruction to return the result.
A possible equation would be:
(function () {
var day = fieldname2,
days = fieldname6,
years = fieldname11,
rate = fieldname7,
total = 0,
temp = 0,
price = day * days;
for (var i = 1; i <= years; i++) {
price = calprice(price, rate);
total = total + price;
};
return PREC(total,2);
})()
Best regards.