• Resolved hheyhey568

    (@hheyhey568)


    Hello Team,
    Thanks for your support as always!

    Need your support to do the following:
    var variable1,variable2,variable3,variable4;

    variable1=fieldname1;
    variable2=fieldname2;
    variable3=fieldname3;
    variable4=fieldname4;

    if(AND(variable1==”Material1″,variable2==”class1″)) variable3=100,variable4=150;
    if(AND(variable1==”Material1″,variable2==”class1″)) variable5=120,variable6=200;

    getField(5).setVal(variable3);
    getField(6).setVal(variable4);
    getField(7).setVal(variable5);
    getField(8).setVal(variable6);

    Question 1 : Am I correct with the if statement?

    Question2: Finally I want to create a table with the variable3 v/s variable4 , variable5 vs variable6 as I have many if statements.

    Question3: How to create a chart with X axis value as variable3 & variable5 and Y Axis value as variable4 & variable6?

    Thanks,

    regards,

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    No, I’m sorry, the equation is incorrect.

    You should use commas between variables in the declaration section (var) only. Furthermore, if multiple instructions belongs to an if conditional statements, you must create blocks with the {} symbols.

    The conditions in your second if conditional statements are just the same of the first one AND(variable1=="Material1",variable2=="class1"), so, you should assign every value in a unique if block:

    
    (function(){
    var variable1 = fieldname1, variable2 = fieldname2, variable3 = fieldname3, variable4 = fieldname4;
    
    if(AND(variable1=="Material1",variable2=="class1"))
    {
     variable3=100;
     variable4=150;
     variable5=120;
     variable6=200;
    }
    
    getField(5).setVal(variable3);
    getField(6).setVal(variable4);
    getField(7).setVal(variable5);
    getField(8).setVal(variable6);
    
    })()
    

    If you want to generate a table with variable3 vs variable4, and variable5 vs variable6. You can use the calculated field as an auxiliary field and display the results into an “HTML Content” field.

    You can insert an “HTML Content” field with a div tag as its content where display the table:

    <div class="table-here"></div>

    And the equation would be:

    
    (function(){
    var variable1 = fieldname1, variable2 = fieldname2, variable3 = fieldname3, variable4 = fieldname4, table;
    
    if(AND(variable1=="Material1",variable2=="class1"))
    {
     variable3=100;
     variable4=150;
     variable5=120;
     variable6=200;
    }
    
    getField(5).setVal(variable3);
    getField(6).setVal(variable4);
    getField(7).setVal(variable5);
    getField(8).setVal(variable6);
    
    table = '<table><tr><td>'+variable3+'</td><td>'+variable4+'</td></tr>'+
            '<tr><td>'+variable5+'</td><td>'+variable6+'</td></tr></table>';
    
    jQuery('.table-here').html(table);
    })()
    

    Regarding the charts, my apologies, it is a commercial feature, and we are not allowed to support any customers in these forums.

    For pro or commercial product support please contact us directly on our site. This includes any pre-sales topics as well.

    Commercial products are not supported in these forums. We will happily answer this and any other questions you can have on our own site.

    Thank you.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘if statement to set two variables’ is closed to new replies.