• Resolved Lara C

    (@larissacas)


    Hi,

    I need a calculator to show costumers the discounts along the days of service: it’s a hotel for cats.

    So, at Excel the formula is:
    =IF(F19<=15; F18*F19*72; IF(F19<=30; F18*F19*72*0,94; IF(F19>30; F19*F18*72*0,91)))

    And, following the tips, I wrote in the plugin like this:
    (function(){
    if(fieldname6<=15) return fieldname6*fieldname2*72;
    if(fieldname6<=30) return fieldname6*fieldname2*67.7;
    if(fieldname6>30) return fieldname6*fieldname2*65.5;
    })();

    The simple formula (fieldname6*fieldname2*72) works fine. But always when I write the function, it’s not showing up.

    I made the changes to classic version, and still nothing.

    Is there anything that I’m missing about the plugin? Is there anything else to write for function code?

    I’m willing to buy the PRO version, but, even if I buy it, is there a chance that this problems continue to happen? Because it’s a little expensive for Brazil (almost R$300,00 for PRO).

    Thanks.

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @larissacas

    The issue is simple. You have created an infinite loop between the dependency and the equation associated to the fieldname4

    In the fieldname4 field you have defined the fieldname6 as dependent on the result of the equation, and the equation uses the fieldname6 field. So, after evaluate the equation the dependency is checked provoking the fieldname6 triggers the evaluation of the equation closing the infinite loop.

    Best regards.

    Thread Starter Lara C

    (@larissacas)

    @codepeople thanks for answering.

    But how can I fix it? How is the right way to write this condition?

    And I need to do other one, with conditions to fieldname6 and fieldname2 as well, I already have the formula at Excel, working fine. So I just need to understand the logic of the plugin, so I can rewrite it properly.

    Plugin Author codepeople

    (@codepeople)

    Hello @larissacas

    You cannot to use a field in the equation, and define it as dependent on the result of the same equation.

    I recommend you to remove the dependency defined in the settings of the calculated field (fieldname4)

    Best regards.

    Thread Starter Lara C

    (@larissacas)

    @codepeople so you are saying that this plugin won’t work for me?

    It depends on the number of the days, that the costumer write on the field, so he get a discount or not. And progressive discounts.

    1 up to 15 days, no discount
    16 up to 30 days, 6%
    more then 30, 9%.

    How can I put this condition as non dependent?

    Plugin Author codepeople

    (@codepeople)

    Hello @larissacas

    The plugin is perfect for you, but you are not using it properly. You are confusing the equations with the dependencies. In your case you don’t need a dependency.

    – Clear the dependencies section in the settings of the calculated field (fieldname4),

    – and edit the equation as follows:

    
    (function(){
    var r = fieldname6*fieldname2;
    if(fieldname6<=15) return r*72;
    if(fieldname6<=30) return r*67.7;
    return r*65.5;
    })()
    

    and that’s all.
    Best regards.

    Thread Starter Lara C

    (@larissacas)

    Thank you. I did that, and the form still not showing.. (gataria.com.br/testes)

    What else can I do?

    BTW, I already did another two forms, with two variables:

    (function(){
    var r = fieldname6;
    var b = fieldname2;
    if(and(fieldname6<=15, fieldname2=1)) return r*105;
    if(and(fieldname6<=15, fieldname2>1)) return (105+((b*25)-25))*r;
    if(and(fieldname6<=30, fieldname2=1)) return r*105*0.94;
    if(and(fieldname6<=30, fieldname2>1)) return (105+((b*25)-25))*r*0.94;
    if(and(fieldname6>30, fieldname2=1)) return r*105*0.91;
    if(and(fieldname6>30, fieldname2>1)) return (105+((b*25)-25))*r*0.91;
    })();

    Is that correct? Not using them in any page yet.

    Plugin Author codepeople

    (@codepeople)

    Hello @larissacas

    I’m sorry, but I need you follow my instructions or I cannot help you. You must to remove the dependency defined in the settings of the calculated field. In the settings of the calculated field you have defined the following dependency:

    “if value is less than or equal to 15 then display the fieldname6”

    delete it.

    Concerning to your new equation, it includes multiple errors:

    – First, the javascript language is case sensitive, the “AND” operation must be entered in uppercase.

    – Second, in javascript the operator for equality is the double sign “==”, because the sign “=” is used for assignment.

    For example:

    
    if(AND(fieldname6<=30, fieldname2==1)) return r*105*0.94;
    

    Best regards.

    Thread Starter Lara C

    (@larissacas)

    @codepeople man, I just copied exactly what you told me the last time:

    (function(){
    var r = fieldname6*fieldname2;
    if(fieldname6<=15) return r*72;
    if(fieldname6<=30) return r*67.7;
    return r*65.5;
    })()

    and it is not working.

    About the second code, I’ll adjust.

    Plugin Author codepeople

    (@codepeople)

    Hello @larissacas

    Please, read my tickets, YOU MUST TO DELETE THE DEPENDENCY. Please, look the screenshot:

    Best regards.

    Thread Starter Lara C

    (@larissacas)

    You were not clear about that. I removed it, thank, working just fine!

    I don’t anything about JS, I just copy and paste the rules, when I find them somewhere.

    We’ll test this free version, but I think it’ll be very useful in a pro or platinum version.

    Thanks.

    Plugin Author codepeople

    (@codepeople)

    Hello @larissacas

    Thank you very much for letting me know that everything is working properly now.

    Best regards.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Form not showing with Function’ is closed to new replies.