• Resolved pexel

    (@pexel)


    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

    (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 11 months, 1 week ago by pexel.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @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:

    
    (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

    (@pexel)

    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.

    (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?

    (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 11 months, 1 week ago by pexel.
    • This reply was modified 11 months, 1 week ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @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

    Best regards.

    Thread Starter pexel

    (@pexel)

    I’m totally confused. It shouldn’t be too difficult.
    I make calculations for each criterion.

    criterion1
    criterion2
    criterion3

    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

    (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 11 months, 1 week ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @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:

    if (fieldname38|r.length === 1) {
        kriter4 = fieldname25 / 120;
      } else {
        kriter4 = 0;
      }

    Best regards.

    Thread Starter pexel

    (@pexel)

    What will be the rule if many options are chosen, regardless of A, B, C, D?

    Code 1

    if (fieldname38|r.length === 1) {
        kriter4 = fieldname25 / 120;
      } else {
        kriter4 = 0;
      }

    code 2

    if (fieldname38|r.length === 1) {
        kriter5 = fieldname30 / 120;
      } else {
        kriter5 = 0;
      }
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    if( 1 < fieldname38|r.length )

    Best regards.

    Thread Starter pexel

    (@pexel)

    I thank you very much

    Thread Starter pexel

    (@pexel)

    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

    (@codepeople)

    Hello @pexel

    Please, include your final equation code.

    Best regards.

    Thread Starter pexel

    (@pexel)

    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

    (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

    (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

    (@codepeople)

    Hello @pexel

    You can check the different alternatives:

    
    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

    (@pexel)

    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.

    (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

    (@codepeople)

    Hello @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

    (@pexel)

    understood thanks.

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