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.
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/
Excellent !!!! It has been a pleasure to help you.
Best regards.
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)
Hello @needfeed
Who is the fieldname111 field? Your form does not included a fieldname111.
Best regards.
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)
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.
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 🙂
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.
Understood. Thanks again for your help, codepeople 🙂