• Resolved Sportuojantys

    (@needfeed)


    Hello, I wanted to ask help about merging 3 calculator, which I made with CFF to 1 calculator with extra field, coz their functions are similar, I just can‘t create the merged formula so I wanted to ask a help.
    In the new calculator I will add 1 more selection (let‘s call it ‘fieldnameX‘) which includes all 3 parameters below: (those parameters are: ‘gain’ weight; ‘lose’ weight; ‘remain’ same weight).
    New field will be called: fieldnameX. This field will have variables: ‘gain’, ‘lose’, ‘remain’.
    These 3 calculators and their formulas are:
    1. Calculator for gaining weight (link: https://sportuojantys.lt/skaiciuokles/makroelementu-skaiciuokle-auginant-mase/)
    Formula for kcal answer:
    PREC(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?42*fieldname2:52*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?47*fieldname2:36*fieldname2))

    2. Calculator for losing weight. (link: https://sportuojantys.lt/skaiciuokles/makroelementu-skaiciuokle-metant-svori/)
    Formula for kcal answer:
    PREC(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?28*fieldname2:38*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?35*fieldname2:25*fieldname2))

    3. Calculator for remaining the same weight (link: https://sportuojantys.lt/skaiciuokles/makroelementu-skaiciuokle-palaikant-svori/)
    Formula for kcal answer:
    PREC(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?33*fieldname2:42*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?39*fieldname2:31*fieldname2))

    I know that I need more of ?((()))“ symbols in merged formula but I just can‘t figure it out, so maybe you can help me?

    Thanks in advance…

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @needfeed

    You only need an additional field for goals and some conditional statements in the equation. For example, assuming you have the fieldname123 field in the form with the options:

    gain weight
    lose weight
    remain the same weight

    The equation to group all these case can be implemented as follows:

    (function(){
    if(fieldname123 == 'gain weight') return ROUND(fieldname3=='Vyras'?(fieldname4=='3-4 treniruot?s'?42*fieldname2:52*fieldname2):(fieldname4=='5 ir daugiau treniruo?i?'?47*fieldname2:36*fieldname2));
    
    if(fieldname123 == 'lose weight') return ROUND(fieldname3=='Vyras'?(fieldname4=='3-4 treniruot?s'?28*fieldname2:38*fieldname2):(fieldname4=='5 ir daugiau treniruo?i?'?35*fieldname2:25*fieldname2));
    
    if(fieldname123 == 'remain the same weight') return ROUND(fieldname3=='Vyras'?(fieldname4=='3-4 treniruot?s'?33*fieldname2:42*fieldname2):(fieldname4=='5 ir daugiau treniruo?i?'?39*fieldname2:31*fieldname2));
    })()

    And that’s all.

    Best regards.

    Thread Starter Sportuojantys

    (@needfeed)

    CodePeople, thank you for such a fast response.
    You have unique mindset, I’m glad that I recommended your CFF for all my friends because you deserve more attention, CFF is da best ??
    Take a look at merged calculator, thanks to you ??
    https://sportuojantys.lt/skaiciuokles/makroelementu-skaiciuokle-metant-svori/

    Plugin Author codepeople

    (@codepeople)

    Excellent !!!! It has been a pleasure to help you.

    Best regards.

    Thread Starter Sportuojantys

    (@needfeed)

    Hey, codepeople, I wanted to ask 1 more function of a field:
    is it possible, that fieldname111 would be hiden until I select option “gain weight” AND click CALCULATE? (if I select option “lose weight” AND click CALCULATE, this field shouldn’t show up)

    Plugin Author codepeople

    (@codepeople)

    Hello @needfeed

    Who is the fieldname111 field? Your form does not included a fieldname111.

    Best regards.

    Thread Starter Sportuojantys

    (@needfeed)

    Yeah, it was just example ??
    I merged 4th calculator to our previous version. It it looks like this:
    https://sportuojantys.lt/skaiciuokles/dienos-kaloriju-normos-skaiciuokle/
    That 4th option in first field is little different than other 3, coz there are 2 more parameters: height and age, but that’s not the case ??

    Full formula (for kcal only):

    (function(){
    if(fieldname9 == ‘auginti’) return ROUND(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?42*fieldname2:52*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?47*fieldname2:36*fieldname2));

    if(fieldname9 == ‘mesti’) return ROUND(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?28*fieldname2:38*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?35*fieldname2:25*fieldname2));

    if(fieldname9 == ‘laikyti’) return ROUND(fieldname3==’Vyras’?(fieldname4==’3-4 treniruot?s’?33*fieldname2:42*fieldname2):(fieldname4==’5 ir daugiau treniruo?i?’?39*fieldname2:31*fieldname2));

    if(fieldname9 == ‘isgyventi’) return ROUND(fieldname3==’Vyras’?(66+(13.75*fieldname2)+(5*fieldname10)-(6.76*fieldname12)):(655+(9.6*fieldname2)+(1.85*fieldname10)-(4.7*fieldname12)));

    })()

    My question: how to make fields below the CALCULATE button (those fields, where the answers is written), to appear ONLY AFTER clicking the CALCULATE button?
    These 4 answer fields are:
    fieldname1 (kcal)
    fieldname6 (proteins)
    fieldname7 (carbs)
    fieldname8 (fats)

    Plugin Author codepeople

    (@codepeople)

    Hello @needfeed

    Please, follow the steps below:

    1. Enter the class name: hide into the “Add CSS Layout Keywords” attributes of fields, fieldname1, fieldname6, fieldname7, and fieldname8.

    2. Enter the following piece of code into the onlick event of the button:

    jQuery('#fbuilder .hide').removeClass('hide');

    And that’s all.
    Best regards.

    Thread Starter Sportuojantys

    (@needfeed)

    Thanks, you can click the link I have posted, to see the results.
    Now those 4 field appearing like we needed, but there are 2 problems:
    1. When you once click the CALCULATE button, and then change the first option (gain, remain, lose weight or basic weight), the results 4 fields aren’t disappearing and their numbers are remaining the same like it was with last calculation, until you click CALCULATE again.
    2. When in the first option you select the 4th parameter (basic calories), in the results section, appear all 4 fields:
    fieldname1 (kcal)
    fieldname6 (proteins)
    fieldname7 (carbs)
    fieldname8 (fats)

    But we only need fieldname1 (kcal).
    Before your example, I tried to use “Dependencies” option where I set that fieldname6 (proteins), fieldname7 (carbs) and fieldname8 (fats) only show with selections Nr. 1, 2 and 3 in the first option, but I deactivated this option because it was not comfortable with your example with ‘hide’ function ??

    Plugin Author codepeople

    (@codepeople)

    Hello @needfeed

    That is not an issue. Your equations are evaluated when you press the “Calculate” button. If you change the entry fields, the results are not modified until you press the “Calculate” button again to reevaluate the equations.

    Another thing is to hide the fields for results when you enter any value in the entry fields.

    Note that it is not part of the plugin. This request is specific to your project and must be implemented as part of the form’s code.

    You can insert an “HTML Content” field in the form with the piece of code:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname9_"],[id*="fieldname3_"],[id*="fieldname2_"],[id*="fieldname4_"]',function(){
    jQuery('[class*="fieldname1_"],[class*="fieldname6_"],[class*="fieldname7_"],[class*="fieldname8_"]').addClass('hide');
    });
    </script>
    

    Please, note the support service does not cover the implementation of the users’ projects. If you need someone to implement your project, you can contact us through our private website: Click Here

    Best regards.

    Thread Starter Sportuojantys

    (@needfeed)

    Understood. Thanks again for your help, codepeople ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘3 calculators merge to 1’ is closed to new replies.