• Resolved pexel

    (@pexel)


    Hello;
    We need your help with something. For example, when printing out 2 different results with 2 options, how do we show the result according to the option?

    For example; If I choose the 1st criterion, A will write the results (Hiding the B result). If I choose the 2nd criterion, B will write the result. (A will hide the results)

    Result screen code;

    <table><tbody><tr>
        <td style="text-align: left;"><b class="kriter1-aciklama mobile-aciklama">Hesaplama Sonucu :</b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter1-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr><tr>
        <td style="text-align: left;"><b class="kriter2-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter2-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr><tr>
        <td style="text-align: left;"><b class="kriter3-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter3-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr><tr>
        <td style="text-align: left;"><b class="kriter4-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter4-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr><tr>
        </td></tr></tbody></table>

    Option A (criterion3, criterion4) gives the result of option B (criterion1, criterion2).
    In summary, how do we ensure that the selected results are reflected on the screen?

    Sample : Hesaplama

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    If you have multiple tags with data-cff-field="fieldname19", all of them will contain the fieldname19 value. If you want to display a tag or another the solution would be different.

    Assigns a different class name to the tr tag as follows:

    <table><tbody>
    
    <tr class="choice-a">
        <td style="text-align: left;"><b class="kriter1-aciklama mobile-aciklama">Hesaplama Sonucu :</b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter1-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr>
    
    <tr class="choice-b">
        <td style="text-align: left;"><b class="kriter2-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter2-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr>
    
    <tr class="choice-c">
        <td style="text-align: left;"><b class="kriter3-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter3-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr>
    
    <tr class="choice-d">
        <td style="text-align: left;"><b class="kriter4-aciklama mobile-aciklama"></b></td><td style="text-align: right;"><b><span data-cff-field="fieldname19"class="kriter4-sonuc mobile-sonuc" style="color:#ff6504;"></span></b><text style="color:#ff6504;"> </text></td>
    </tr>
    
    </tbody></table>

    Now, assuming your equation is fieldname1+fieldname2, and fieldname3 is a radio button field with four choices whose values are: a, b, c, and d

    Edit the equation as follows:

    
    (function(){
    
    jQuery('.choice-a,.choice-b,.choice-c,.choice-d').hide();
    
    if(fieldname3 == 'a') jQuery('.choice-a').show();
    if(fieldname3 == 'b') jQuery('.choice-b').show();
    if(fieldname3 == 'c') jQuery('.choice-c').show();
    if(fieldname3 == 'd') jQuery('.choice-d').show();
    
    return fieldname1+fieldname2;
    
    })()

    Best regards.

    Thread Starter pexel

    (@pexel)

    Now, these are the result codes that give results. I can run the code you gave me without any problems.

    For example, while writing the result of criterion1, I want to hide criterion2.

    (function(){
        var kriter1 = 0;
        kriter1 = prec(fieldname2/0.39370,0);
    
        jQuery('#calculation-kriter1').html(kriter1);
        jQuery('.kriter1-aciklama').html('Ekran K??egeni : ');
        jQuery('.kriter1-sonuc').html(kriter1+' cm');
    
        return kriter1;
    })();
    (function(){
    var kriter2;
    if(fieldname8 == 1) {
    kriter2=prec((fieldname1*0.8),2);
    };
    
    if(fieldname8 == 2) {
    kriter2=prec((fieldname1*0.871575),2);
    };
    
    if(fieldname8 == 3) {
    kriter2=prec((fieldname1*0.919145),2);
    };
    
    
        jQuery('#calculation-kriter2').html(kriter2);
        jQuery('.kriter2-aciklama').html('Geni?lik : ');
        jQuery('.kriter2-sonuc').html(kriter2+' cm');
    
        return kriter2;
    })();
    • This reply was modified 1 year, 1 month ago by pexel.
    • This reply was modified 1 year, 1 month ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel,

    Please pay attention to my code. The first step in my code is to hide all optional tags:

    jQuery('.choice-a,.choice-b,.choice-c,.choice-d').hide();

    And then, into each if conditional statement, I show the corresponding tag. Ex.

    if(fieldname3 == 'a') jQuery('.choice-a').show();

    You should do the same. Hide first all optional tags and display only the tags that satisfy the criteria.

    Best regards.

    Thread Starter pexel

    (@pexel)

    I understand you, there is no problem in that regard, but the part I cannot explain is this;
    If fieldname4 is A;
    criterion1
    criterion2
    criterion3
    display the result.

    If fieldname4 is B;
    criterion4
    display the result.
    criterion1
    criterion2
    criterion3
    Hide..

    There is a criterion in between. It hides and shows in the code you gave, but since it skips the fieldname4 criteria, it hides them all.

    Our form address: Hesaplama

    Plugin Author codepeople

    (@codepeople)

    Hello @pexel,

    I’m sorry, but I don’t understand your description. But if you want to display more than an element the process is a simple modification to my previous equation as follows:

    (function(){
    
    jQuery('.choice-a,.choice-b,.choice-c,.choice-d').hide();
    
    if(fieldname3 == 'a'){
        jQuery('.choice-a').show();
        jQuery('.choice-b').show();
        jQuery('.choice-c').show();
    }
    if(fieldname3 == 'b') jQuery('.choice-c').show();
    
    return fieldname1+fieldname2;
    
    })()

    Note I included a pair of {} symbols to enclose multiple show element instructions in a same conditional conditional statement.

    A similar implementation would be:

    (function(){
    
    jQuery('.choice-a,.choice-b,.choice-c,.choice-d').hide();
    
    if(fieldname3 == 'a') jQuery('.choice-a,.choice-b.choice-c').show();
    if(fieldname3 == 'b') jQuery('.choice-c').show();
    
    return fieldname1+fieldname2;
    
    })()

    Best regards.

    Thread Starter pexel

    (@pexel)

    This way the code worked.

    I choose criterion A and it shows the result 1,2,3. I choose criterion B and it shows the 4th result. There’s only one small problem left.

    A calculated, I chose B, calculated. I pressed the clear button. When I pressed it, it went to the default position, I said calculate again, the results show zero.

    (function(){
    
        var kriter1 = 0;
        kriter1 = prec(fieldname2/0.39370,0);
    
    jQuery('.choice-a,.choice-b,.choice-c,.choice-d').hide();
    
    if(fieldname4 == 'A'){
        jQuery('.choice-a').show();
        jQuery('.choice-b').show();
        jQuery('.choice-c').show();
    }
    if(fieldname4 == 'B'){
    
        jQuery('.choice-a').hide();
        jQuery('.choice-b').hide();
        jQuery('.choice-c').hide();
    	jQuery('.choice-d').show();
    }	
        jQuery('#calculation-kriter1').html(kriter1);
        jQuery('.kriter1-aciklama').html('Ekran K??egeni : ');
        jQuery('.kriter1-sonuc').html(kriter1+' cm');
    
        return kriter1;
    })();
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel,

    If fieldname4 is a radio buttons field, the piece of code below is redundant because you have hidden those tags above:

    jQuery('.choice-a').hide();
     jQuery('.choice-b').hide();
     jQuery('.choice-c').hide();

    I’m testing your form in https://www.pexpe.com/piksel-cm-cevirme/ and it is working fine from my side.

    Best regards.

    Thread Starter pexel

    (@pexel)

    First of all, I apologize for giving the wrong link address.

    You will understand the problem by doing it this way.

    Step 1 – calculate inches-cm (criterion A) (result sounds correct)
    Step 2 – Calculate cm-inches (criterion B) (result sounds correct)

    After doing step 2, press the clear button. (calculation clearing)
    Step 3- Let’s say calculate again after the cleaning process.

    Results are coming back to zero (This is the problem)

    Corrected Link : Hesaplama

    This problem occurs in all calculations with radio buttons.

    • This reply was modified 1 year, 1 month ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel

    Please edit the onclick event of the reset button as follows:

    this.form.reset();jQuery('[data-cff-field]').html('');fbuilderjQuery.fbuilder['showHideDep']({ 'formIdentifier' : '_1' });

    Best regards.

    Thread Starter pexel

    (@pexel)

    I change the (clear) buttons in all calculation forms in this way to avoid problems.

    • This reply was modified 1 year, 1 month ago by pexel.
    • This reply was modified 1 year, 1 month ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @codepeople

    What option do you have selected through the “Script load method” attribute in the menu option “Calculated Fields Form > Troubleshoot Area & General Settings”?

    Best regards.

    Thread Starter pexel

    (@pexel)

    https://i.hizliresim.com/1eh92jg.JPG

    Should I change all buttons like this? Playing with this setting scares me now.

    • This reply was modified 1 year, 1 month ago by pexel.
    Plugin Author codepeople

    (@codepeople)

    Hello @pexel,

    Please select the “Classic” option and press the “Update” button. Once you modified the script load method, purge your website and browser caches and let me know to check your form again.

    Best regards.

    Thread Starter pexel

    (@pexel)

    I have now made the changes as you said. I would like to ask you which functions should I use in the current “Calculate” and “Clear” buttons? I will revise all forms according to the coding you specified.

    Plugin Author codepeople

    (@codepeople)

    Hello @pexel,

    Excellent !!!

    That was the modification we recommended to you from the plugin website.

    Now, the reset code would be as simple as follows because there is only one instance of the jQuery library on your page:

    RESETFORM(this.form);jQuery('[data-cff-field]').html('');

    Best regards.

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