• Resolved cncladmin

    (@cncladmin)


    Hi there,

    I’m wanting to include a comma as a thousands separator in the longer calculated digits of my form. I initially simply added “,” into the “symbol for grouping thousands” box, and it worked fine.

    But then I needed to use a more complex equation, and following the instructions in your documentation, I inserted the following equation into the equation editor for this field:

    (function(){

    if(fieldname11==”Vegan”) return ROUND(((fieldname3*365)+(fieldname2*30)+fieldname8)*6.32)+” whole meals”;

    if(fieldname11==”Lacto-ovo Vegetarian”) return ROUND(((fieldname3*365)+(fieldname2*30)+fieldname8)*5.14)+” whole meals”;

    })();

    …the equation works perfectly fine. However, now the comma separator has disappeared, even though I still have it in the “symbol for grouping thousands” box. Do you know how I can reinsert the comma separator into these figures. Do I need to incorporate it into this code somehow now?

    Thanks for your assistance,
    Paris

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

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

    (@codepeople)

    Hello @cncladmin,

    I’ve visited the URL provided but the form is not there.

    Please, configure your calculated field as follows:

    1. Enter the comma symbol (,) into the attribute: “Symbol for grouping thousands”

    2. Enter the text: whole meals into the attribute: “Symbol to display at the end of calculated field”

    3. Finally, edit the equation as follows:

    
    (function(){
    
    if(fieldname11=="Vegan") return ROUND((fieldname3*365+fieldname2*30+fieldname8)*6.32);
    
    if(fieldname11=="Lacto-ovo Vegetarian") return ROUND((fieldname3*365+fieldname2*30+fieldname8)*5.14);
    
    })();
    

    and that’s all.
    Best regards.

    Thread Starter cncladmin

    (@cncladmin)

    Thanks for your very quick reply.

    Your solution works great for this particular field; however, I have other fields that have a slightly more complicated equation, and it doesn’t appear that this solution will work for those, which are all similar to the following:

    (function(){

    if(fieldname11==”Vegan” && fieldname12==”Metric”) return ROUND(((fieldname3*365)+(fieldname2*30)+fieldname8)*2.488)+” kg”;

    if(fieldname11==”Lacto-ovo Vegetarian” && fieldname12==”Metric”) return ROUND(((fieldname3*365)+(fieldname2*30)+fieldname8)*1.531)+” kg”;

    if(fieldname11==”Vegan” && fieldname12==”Imperial”) return ROUND((((fieldname3*365)+(fieldname2*30)+fieldname8)*2.488)*2.2)+” lb”;

    if(fieldname11==”Lacto-ovo Vegetarian” && fieldname12==”Imperial”) return ROUND((((fieldname3*365)+(fieldname2*30)+fieldname8)*1.531)*2.2)+” lb”;

    })();

    …this is because the “symbol to display at the end of the field” is different depending upon the conditions (“lb” vs. “kg” depending upon whether the person selected “imperial” or “metric”). Do you know how I can insert the thousands separators into these figures while still allowing for the conditional “display at the end of the field.”

    …btw, I apologize for not giving more info on the url. To see the table, go to the bottom of this page: http://cncl.org.nz/plant-based/

    Thanks,
    Paris

    Plugin Author codepeople

    (@codepeople)

    Hello @cncladmin,

    The solution in this case would be call one of methods of the plugin to format the number before concatenate the text.

    Leave in blank the attributes in the field’s settings, and then, edit the equation as follows:

    
    (function(){
    var format = fbuilderjQuery.fbuilder.calculator.format, 
    config = {groupingsymbol:',', decimalsymbol:'.'};
    
    if(fieldname11=="Vegan" && fieldname12=="Metric") return format(ROUND((fieldname3*365+fieldname2*30+fieldname8)*2.488), config)+" kg";
    
    if(fieldname11=="Lacto-ovo Vegetarian" && fieldname12=="Metric") return format(ROUND((fieldname3*365+fieldname2*30+fieldname8)*1.531), config)+" kg";
    
    if(fieldname11=="Vegan" && fieldname12=="Imperial") return format(ROUND((fieldname3*365+fieldname2*30+fieldname8)*2.488*2.2), config)+" lb";
    
    if(fieldname11=="Lacto-ovo Vegetarian" && fieldname12=="Imperial") return format(ROUND((fieldname3*365+fieldname2*30+fieldname8)*1.531*2.2), config)+" lb";
    
    })();
    

    Best regards.

    Thread Starter cncladmin

    (@cncladmin)

    Perfect! Thanks so much,
    Paris

    Plugin Author codepeople

    (@codepeople)

    Hello @cncladmin,

    It has been a pleasure.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘thousands separator comma disappeared’ is closed to new replies.