• Resolved kasper1234

    (@kasper1234)


    How do I make this result visible in the form field,- is there some kind of syntax error?

    I want it to show the value of “result” var.

    Kind regards

    K

    (function(){
    var discount = 1;
    var result = fieldname2*fieldname5*(3500*discount)+((fieldname4*400)*(fieldname2*fieldname5));

    if(fieldname5 = “1,5”) discount = 1;
    if(fieldname5 = “1,6”) discount = 1,1;
    if(fieldname5 = “1,7”) discount = 1,2;
    if(fieldname5 = “1,8”) discount = 1,5;
    if(fieldname5 = “1,9”) discount = 1,8;

    return result;

    })()

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

    (@codepeople)

    Hello @kasper1234,

    There are some syntax errors in your equation:

    First, in javascript the operator for equality is the double symbol: “==” because the symbol: “=” is used for assignment.

    Second, in javascript the symbol for decimals is the dot (.) and not the comma (,)

    Third, the block that determine the discount has no sense if it below the code that uses the it.

    I guess you are using the comma symbol as decimal separator in other fields, if it the case, please, fix them.

    The correct equation would be:

    
    (function () {
    	var discount = 1;
    
    	if (fieldname5 == 1.5) discount = 1;
    	if (fieldname5 == 1.6) discount = 1.1;
    	if (fieldname5 == 1.7) discount = 1.2;
    	if (fieldname5 == 1.8) discount = 1.5;
    	if (fieldname5 == 1.9) discount = 1.8;
    
    	return fieldname2*fieldname5*3500*discount + fieldname4*400*fieldname2*fieldname5;
    
    })()
    

    and that’s all.
    Best regards.

    Thread Starter kasper1234

    (@kasper1234)

    Thanks, -it works ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get value out of function’ is closed to new replies.