Title: Criterion Problems
Last modified: January 10, 2024

---

# Criterion Problems

 *  Resolved [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problems/)
 * 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?
 *     ```wp-block-code
       (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](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problems/#post-17331913)
 * Hello [@pexel](https://wordpress.org/support/users/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:
 *     ```wp-block-code
       // Assign the value to kriter1
       ```
   
 * As follows:
 *     ```wp-block-code
       /* 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:
 *     ```wp-block-code
       var kriter1 = '', aa = 0, bb = 0;
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problems/#post-17332053)
 * thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Criterion Problems’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [pexel](https://wordpress.org/support/users/pexel/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problems/#post-17332053)
 * Status: resolved