• Resolved applejack1923

    (@applejack1923)


    Hi

    How can I have comma separator for numbers i.e. 1,000 in a calculated field which are injected into an HTML block.

    I tried using .toLocaleString(‘en’) in the jQuery call but it didn’t work.

    This needs to be on the display only not the value of the calcualted field as there are addiional calculations made using the results.

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

    (@codepeople)

    Hello @applejack1923

    Please, describe your equation.

    Best regards.

    Plugin Author codepeople

    (@codepeople)

    Hello @applejack1923

    Please, note the plugin includes the FORMAT operation (https://cff.dwbooster.com/documentation#mathematical-module)

    FORMAT(1000, {groupingsymbol:",", decimalsymbol:"."})

    Returns 1,000

    Best regards.

    Thread Starter applejack1923

    (@applejack1923)

    Hi

    This is an example of one of functions so I would be very grateful if you could show how to integrate.

    THanks.

    (function(){
    
    	if(fieldname4 == 'Man' && fieldname3 == 'Imperial' && fieldname8 > 0) var bmr = 66 + (6.2 * fieldname8) + (12.7 * ((fieldname6 * 12) + fieldname7)) - (6.8*fieldname5);
    	if(fieldname4 == 'Man' && fieldname3 == 'Metric' && fieldname10 > 0) var bmr = 66 + (13.7 * fieldname10) + (5 * fieldname9) - (6.8 * fieldname5);
    	if(fieldname4 == 'Woman' && fieldname3 == 'Imperial' && fieldname8 > 0) var bmr = 655 + (4.4 * fieldname8) + (4.6 * ((fieldname6 * 12) + fieldname7)) - (4.7 * fieldname5);
    	if(fieldname4 == 'Woman' && fieldname3 == 'Metric' && fieldname10 > 0) var bmr =  655 + (9.6 * fieldname10) + (1.8 * fieldname9) - (4.7 * fieldname5); 
    	
    	jQuery('.step1 div strong').html(bmr.toFixed(0));
    return bmr;
    })();
    Plugin Author codepeople

    (@codepeople)

    Hello @applejack1923

    The code would be:

    (function(){
    	if(fieldname4 == 'Man' && fieldname3 == 'Imperial' && fieldname8 > 0) var bmr = 66 + (6.2 * fieldname8) + (12.7 * ((fieldname6 * 12) + fieldname7)) - (6.8*fieldname5);
    	if(fieldname4 == 'Man' && fieldname3 == 'Metric' && fieldname10 > 0) var bmr = 66 + (13.7 * fieldname10) + (5 * fieldname9) - (6.8 * fieldname5);
    	if(fieldname4 == 'Woman' && fieldname3 == 'Imperial' && fieldname8 > 0) var bmr = 655 + (4.4 * fieldname8) + (4.6 * ((fieldname6 * 12) + fieldname7)) - (4.7 * fieldname5);
    	if(fieldname4 == 'Woman' && fieldname3 == 'Metric' && fieldname10 > 0) var bmr =  655 + (9.6 * fieldname10) + (1.8 * fieldname9) - (4.7 * fieldname5); 
    	
    	jQuery('.step1 div strong').html(FORMAT(bmr.toFixed(0), {groupingsymbol:",", decimalsymbol:"."}));
    return bmr;
    })();

    Best regards.

    Thread Starter applejack1923

    (@applejack1923)

    Hi

    That doesn’t work I’m afreaid it stops the calculation from working.

    Plugin Author codepeople

    (@codepeople)

    Hello @applejack1923

    Please, indicate the link to the form to check the equation in action.

    Best regards.

    Thread Starter applejack1923

    (@applejack1923)

    Hi

    This works

    https://minimalistbody.feelingsneaky.com/macrocalculator/

    This doesn’t

    https://minimalistbody.feelingsneaky.com/macrocalculator-test/

    It is just the 1st page you need to fill in the fields

    Plugin Author codepeople

    (@codepeople)

    Hello @applejack1923

    The equation is correct. It is populating the tag, but the “HTML Content” field fieldname19 was configured as dependent on the equation’s result, and you have removed the return bmr; code from the equation. So, your equation is returning no value.

    Best regards.

    Thread Starter applejack1923

    (@applejack1923)

    Damn copy and paste.

    It is working fine now.

    Thanks for your help, much appreciated.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Comma separator for numbers injected into HTML block’ is closed to new replies.