• Resolved pexel

    (@pexel)


    Hello;
    I couldn’t reach a conclusion on one criterion. My code is located below. If fieldname26 is A, I want it to take the values aa bb oo, if B, the corresponding values, and finally criterion1 = aa + bb, whichever option I choose. But there is no result, what am I doing wrong?

    (function() {
      var kriter1 = '';
    
    
      if (fieldname26 === 'A') {
        aa = 75;
        bb = 0;
        oo = 0;
      } else if (fieldname26 === 'B') {
        aa = 0;
        bb = 75;
        oo = 0;
      } else if (fieldname26 === 'O') {
        aa = 0;
        bb = 0;
        oo = 100;
      } else if (fieldname26 === 'AB') {
        aa = 50;
        bb = 50;
        oo = 0;
      }
    
      if (fieldname28 === 'A') {
        ab = 75;
        bo = 25;
        oo = 0; 
      } else if (fieldname28 === 'B') {
        ab = 0;
        bo = 75;
        oo = 0; 
      } else if (fieldname28 === 'O') {
        ab = 0;
        bo = 0;
        oo = 100;
      } else if (fieldname28 === 'AB') {
        ab = 50;
        bo = 50;
        oo = 0; 
      }
    
    
      if (fieldname25 === 'N' && fieldname29 === 'N') {
        rhFaktoru1 = 0;
        rhFaktoru2 = 100;
      } else if (fieldname25 === 'P' && fieldname29 === 'N') {
        rhFaktoru1 = 75;
        rhFaktoru2 = 25;
      } else if (fieldname25 === 'N' && fieldname29 === 'P') {
        rhFaktoru1 = 75;
        rhFaktoru2 = 25;
      } else if (fieldname25 === 'P' && fieldname29 === 'P') {
        rhFaktoru1 = 93.75;
        rhFaktoru2 = 6.25;
      }
    
      kriter1 = aa+bb; // Assign the value to kriter1
    
      jQuery('#calculation-kriter1').html(kriter1);
      jQuery('.kriter1-aciklama').html('Hata Mesaj?: ');
      jQuery('.kriter1-sonuc').html(kriter1);
    
      return [kriter1];
    })();
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    There are two issues with your equation.

    First, do not use single-line comments in the equations. The plugin minifies the equations, and the use of single-line comments can break their code. If you want to include comments in the equations, please use comments with block structure.

    In short, edit:

    // Assign the value to kriter1

    As follows:

    /* Assign the value to kriter1 */

    Second, I don’t know if you’re initializing the aa and bb variables in another place. But if none of the conditional statements is satisfied, the aa and bb variables do not exist, and the sum kriter1 = aa+bb; will throw an error.

    The correct would be to initialize the variables as you initialized kriter1:

    var kriter1 = '', aa = 0, bb = 0;

    Best regards.

    Thread Starter pexel

    (@pexel)

    thanks ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Criterion Problems’ is closed to new replies.