• Resolved henrycproject

    (@henrycproject)


    Hi there.

    What is wrong with my code:

    (function(){

    if(fieldname3==’US’&&fieldname3==’MD’&&fieldname5<= 0.4) return2;

    })();

    Thanks a lot for your help with this.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello,

    I believe there is a space missing between returnand 2. The below should work.

    (function(){
    
    if(fieldname3==’US’&&fieldname3==’MD’&&fieldname5<= 0.4) return 2;
    
    })();
    Thread Starter henrycproject

    (@henrycproject)

    Hi Damn! … no, it isn’t working with space between return and 2.

    I have a dropdown selection field at fieldname3 amd fieldname4 and a number field at fieldname5.

    Any other ideas?

    Thanks a lot for your help in this matter.

    Plugin Author codepeople

    (@codepeople)

    Hello @henrycproject and @greedymind,

    The single quotes that are using both in the code are wrong, you are using the single quotes symbols ’’ but the correct ones supported by javascript are ''

    So, the equation would be:

    (function(){
    
    if(fieldname3=='US' && fieldname3=='MD' && fieldname5 <= 0.4) return 2;
    
    })();

    By the way, the equation returns a result only if the condition is satisfied.

    If the issue persists, please, include in your ticket the link to the webpage where the form is inserted.

    Best regards.

    Thread Starter henrycproject

    (@henrycproject)

    Thanks codeople… have copied your code but it still not working … ??

    Plugin Author codepeople

    (@codepeople)

    Hello @henrycproject,

    I’m sorry, but I cannot help you if you don’t include the link to the webpage where the form is inserted.

    Best regards.

    Thread Starter henrycproject

    (@henrycproject)

    https://bpeshopping.com/contact-us/

    • This reply was modified 6 years, 11 months ago by henrycproject.
    Thread Starter henrycproject

    (@henrycproject)

    I did included it… it is hold for moderation… within 72 hours…

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Spam queue. The 72 hours just means someone will come along and de-queue your reply as I’ve just done.

    Thread Starter henrycproject

    (@henrycproject)

    Codepeople, the link is alive here already. Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @henrycproject,

    Your current equation is:

    (function(){
    	
    	if(fieldname3=='US' && fieldname3=='MD' && fieldname5<0.4) return 2.20;
    	if(fieldname3=='US' && fieldname3=='MD' && fieldname5=0.4) return 2.64;
    	if(fieldname5>30) return 'GREUTATE MAXIMA ADMISIBILA 30KG';
    })();

    Now, I will explain all errors in your equation:

    First, fieldname3 cannot be at the same time equal to 'US' and 'MD', so, the first and second conditional statements won’t be valid never.

    Second issue, in javascript the comparison operator for equality is “==” because the symbol “=” is used for assignment, so, in the second rule the correct would be: fieldname5==0.4

    Best regards.

    Thread Starter henrycproject

    (@henrycproject)

    got it… everything is working now! thanks a lot

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Calculation formula’ is closed to new replies.