Hello @fitnesspreponline,
Not directly into a calculated field, because the calculated fields use input tags, and the input tags accepts single line texts. So, if you want to display the equation’s result as a text with multiple lines, my recommendation is to use the calculated field as auxiliary, but display the result in another field like a “HTML Content”:
– Inserts a “HTML Content” field in the form, with the following piece of code as its content:
<div class="equation-result"></div>
– Now, modifies the equation as follows:
(function () {
var result='';
if (fieldname5 == 1)
result = 10*fieldname8*0.454+ 6.25*(fieldname6*12+fieldname7)*2.54-5*fieldname2+5;
if (fieldname5 == 2)
result = 10*fieldname8*0.454+6.25*(fieldname6*12+fieldname7) * 2.54-5*fieldname2-161;
jQuery('.equation-result').html(result);
return result;
})();
– Finally, as the calculated field is used as an auxiliary field, you should tick the checkbox: “Hide Field From Public Page” in its properties.
Best regards.
I tried that, but it still doesn’t show the result on multiple lines. Here’s my code:
(function(){
var cal = ”;
if(fieldname5==1)
cal = (10*(fieldname8*0.454)+6.25*(((fieldname6*12)+fieldname7)*2.54)-5*fieldname2+5);
if(fieldname5==2)
cal = (10*(fieldname8*0.454)+6.25*(((fieldname6*12)+fieldname7)*2.54)-5*fieldname2-161) ;
if(fieldname10==1)
cal = cal * 1.2;
else if(fieldname10==2)
cal = cal * 1.375;
else if(fieldname10==3)
cal = cal * 1.55;
else if(fieldname10==4)
cal = cal * 1.725;
jQuery(‘.equation-result’).html(“Your TDEE is ” + ROUND(cal) + “\n” +” Calories.”);
return cal;
})();
Hello @fitnesspreponline,
Into the div tags, the changes of lines is represented with the tag: <br> and not with “\n”, so, the line of code would be:
jQuery('.equation-result').html("Your TDEE is " + ROUND(cal) + "<br>" +" Calories.");
I’m sorry but this questions are not related directly with our plugin. If you need additional help implementing the formula, you should hire a custom coding service.
Best regards.