Title: Criterion Problem
Last modified: December 17, 2023

---

# Criterion Problem

 *  Resolved [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/)
 * Hello;
   I’m having trouble designing a form. My problem is this;I have a Checkboxes
   area.Here, my criteria are fieldname38 VALUE in the form of A B C D.
 * I write the result as follows;
 * My problem is this; I want it to be calculated when more than one checkbox is
   selected.
 * For example, when both A, B, C and D criteria are selected, or only A or B is
   selected, this field is completely variable.
 * How can I write separately on my results screen?
 * **When we select more than one criterion, the result is written as 0.**
 * [Hesaplama](https://www.pexpe.com?cff-form=228)
 *     ```wp-block-code
       (function() {
         var kriter4 = '';
   
         if (fieldname38 === 'A') {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
   
         jQuery('#calculation-kriter4').html(kriter4);
         jQuery('.kriter4-aciklama').html('Konut Rayiç Bedeli : ');
         jQuery('.kriter4-sonuc').html(FORMAT(PREC(kriter4, 2), {groupingsymbol: ".", decimalsymbol: ","}) + ' TL');
   
         return [kriter4];
       })();
       ```
   
    -  This topic was modified 2 years, 5 months ago by [pexel](https://wordpress.org/support/users/pexel/).

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283619)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * If you access the field with the |r modifier (fieldname38|r) from the equations,
   its value would be an array with the values of ticked choices.
 * To know if only “A” or “B” are selected, or both, you can implement the equation
   similar to:
 *     ```wp-block-code
       (function(){
           var values = fieldname38|r,
               n = values.length;
           if(AND(IN('A', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('B', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('A', values), IN('B', values))) return 'A and B are selected';
       })()
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283638)
 * How do I apply this to each criterion?
 * I wrote the calculation field for each criterion. Separate criteria that print
   results as criterion4 criterion5.
   Can you correct the exact code below? Should
   I apply it to others?
 * **I don’t know what to select because the criteria fields are variable and the
   user will select them.**
   Thanks.
 *     ```wp-block-code
       (function() {
         var kriter4 = '';
           var values = fieldname38|r,
               n = values.length;
           if(AND(IN('A', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('B', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('C', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('D', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('E', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('F', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('G', values), n == 1)) return 'Only A is selected';	
   
           if(AND(IN('H', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('K', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('L', values), n == 1)) return 'Only B is selected';	
   
           if(AND(IN('A', values), IN('B', values), IN('C', values), IN('D', values), IN('E', values), IN('F', values), IN('G', values), IN('H', values), IN('K', values), IN('L', values))) return 'A and B are selected';
   
         if (fieldname38 === 'A') {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
   
         jQuery('#calculation-kriter4').html(kriter4);
         jQuery('.kriter4-aciklama').html('Konut Rayiç Bedeli : ');
         jQuery('.kriter4-sonuc').html(FORMAT(PREC(kriter4, 2), {groupingsymbol: ".", decimalsymbol: ","}) + ' TL');
   
         return [kriter4];
       })();
       ```
   
 * **or Do we need to add such an additional criterion?**
 *     ```wp-block-code
       (function(){
           var values = fieldname38|r,
               n = values.length;
           if(AND(IN('A', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('B', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('C', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('D', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('E', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('F', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('G', values), n == 1)) return 'Only A is selected';	
   
           if(AND(IN('H', values), n == 1)) return 'Only A is selected';
   
           if(AND(IN('K', values), n == 1)) return 'Only B is selected';
   
           if(AND(IN('L', values), n == 1)) return 'Only B is selected';	
   
           if(AND(IN('A', values), IN('B', values), IN('C', values), IN('D', values), IN('E', values), IN('F', values), IN('G', values), IN('H', values), IN('K', values), IN('L', values))) return 'A and B are selected';
       })()
       ```
   
    -  This reply was modified 2 years, 5 months ago by [pexel](https://wordpress.org/support/users/pexel/).
    -  This reply was modified 2 years, 5 months ago by [pexel](https://wordpress.org/support/users/pexel/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283694)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * The code I included in a previous entry was only an example of using the “IN”
   operation to check the different choices ticked in the checkbox field. You need
   to adapt it to your equation.
 * If you need us to implement your project equations, you should contact us directly
   through the plugin website. [Contact us](https://cff.dwbooster.com/customization)
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283706)
 * I’m totally confused. It shouldn’t be too difficult.
   I make calculations for 
   each criterion.
 * criterion1
   criterion2criterion3
 * In the form… The only problem here is the calculation of whatever fieldname38
   is selected, the criterion I wrote. It already calculates when I select a single
   criterion. It is not calculated when I select multiple criteria. I shared the
   address in my first post, you will understand if you examine it.
 * My only request is, if more than one variable is selected, how can I adapt it
   to the above criteria? It sets an example for everyone.
 * I don’t want to waste your time, but I’m very confused. If you show me the way,
   I will do the rest.
   Thanks.
 * Sample codes
 *     ```wp-block-code
       (function() {
         var kriter4 = '';
   
         if (fieldname38 === 'A') {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
   
         jQuery('#calculation-kriter4').html(kriter4);
         jQuery('.kriter4-aciklama').html('Konut Rayiç : ');
         jQuery('.kriter4-sonuc').html(FORMAT(PREC(kriter4, 2), {groupingsymbol: ".", decimalsymbol: ","}) + ' TL');
   
         return [kriter4];
       })();
       ```
   
    -  This reply was modified 2 years, 5 months ago by [pexel](https://wordpress.org/support/users/pexel/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283736)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * Your current equation does the following. If the value of the fieldname38 is 
   the choice A, the value of the kriter4 variable will be fieldname25 / 120, and
   zero otherwise.
 * If you want the value of kriter4 to be fieldname25 / 120 when only one choice
   is selected, no matter if it is A, B, C, or D, the condition could be implemented
   as follows:
 *     ```wp-block-code
       if (fieldname38|r.length === 1) {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283738)
 * What will be the rule if many options are chosen, regardless of A, B, C, D?
 * Code 1
 *     ```wp-block-code
       if (fieldname38|r.length === 1) {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
       ```
   
 * code 2
 *     ```wp-block-code
       if (fieldname38|r.length === 1) {
           kriter5 = fieldname30 / 120;
         } else {
           kriter5 = 0;
         }
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283821)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 *     ```wp-block-code
       if( 1 < fieldname38|r.length )
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283848)
 * I thank you very much
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283861)
 * I have one last question;
   Yes, if we make more than one selection in the last
   code you sent, yes it works.
 * But if the user selects 1, it doesn’t work..
 * How do we solve this equation? If the user selects 1, it doesn’t work, but if
   the user selects more than one, it works.
 * How should we update the code?
 * The code will work whether you select one or more than one.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283864)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * Please, include your final equation code.
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283874)
 * Hello;
   If he selects more than one option then yes it works. But if the user 
   selects only one criterion, it does not work.
 * code 1
 *     ```wp-block-code
       (function() {
         var kriter4 = '';
   
       if( 1 < fieldname38|r.length ) {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
         }
   
         jQuery('#calculation-kriter4').html(kriter4);
         jQuery('.kriter4-aciklama').html('Konut Rayiç : ');
         jQuery('.kriter4-sonuc').html(FORMAT(PREC(kriter4, 2), {groupingsymbol: ".", decimalsymbol: ","}) + ' TL');
   
         return [kriter4];
       })();
       ```
   
 * code 2
 *     ```wp-block-code
       (function() {
         var kriter5 = '';
   
       if( 1 < fieldname38|r.length ) {
           kriter5 = (fieldname29 / 240 + fieldname30);
         } else {
           kriter5 = 0;
         }
   
         jQuery('#calculation-kriter5').html(kriter5);
         jQuery('.kriter5-aciklama').html('Konut Rayiç + Kira : ');
         jQuery('.kriter5-sonuc').html(FORMAT(PREC(kriter5, 2), {groupingsymbol: ".", decimalsymbol: ","}) + ' TL');
   
         return [kriter5];
       })();
       ```
   
 * 15 criteria continue in this way.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283904)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * You can check the different alternatives:
 *     ```wp-block-code
       if( 1 < fieldname38|r.length ) {
   
       /* The code to evaluate if were selected multiple choices */    
   
       } else if( 1 == fieldname38|r.length ) {
   
       /* The code to evaluate if was selected only one choice */
   
       }
       else{
   
       /* The code to evaluate if no choices are selected */
   
       }
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17283972)
 * What exactly will the code be like? I couldn’t get it to work this way. We are
   at the final stage, I will be very grateful if you can help with this.
 *     ```wp-block-code
       (function() {
         var kriter4 = '';
   
         if (1 < fieldname38.length) {
           /* The code to evaluate if multiple choices were selected */
         } else if (1 == fieldname38.length) {
           /* The code to evaluate if only one choice was selected */
         } else {
           kriter4 = fieldname25 / 120;
         } else {
           kriter4 = 0;
   
       /* The code to evaluate if no choices are selected */
   
       }
   
         jQuery('#calculation-kriter4').html(kriter4);
         jQuery('.kriter4-aciklama').html('Konut Rayiç : ');
         jQuery('.kriter4-sonuc').html(FORMAT(PREC(kriter4, 2), { groupingsymbol: ".", decimalsymbol: "," }) + ' TL');
   
         return [kriter4];
       })();
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17284211)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * The plugin support does not cover implementing the users’ projects. If you need
   us to implement your project, you should contact us through the plugin website.
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/criterion-problem/#post-17284286)
 * understood thanks.

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

The topic ‘Criterion Problem’ 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/)

 * 15 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-problem/#post-17284286)
 * Status: resolved