@vctrtdms Sorry for not explaining in details
Personally I think there is no easy native way to achieve the customized currency formatting, so I went with the Javascript way. I guess you’ve also found that piece of code in my file, so it’s basically I call a Javascript function to format the number after it completes its calculation
In terms of your project, I can see in general 3 places requiring currency formatting. And all of these need to call the same javascript function with different input numbers
- Credit of each product - OnPageLoad to initialize the format
- Sum of selected products - OnSelected / OnUnSelected to re-format
- User input credit - Dynamic panel (Plain Label state when complete editing; Edit Text field state when back to edit) OnLostFocus to change state and format the number in plain label state
I attach the Javascript function to a hotspot - OnClick event, so I can simply “Fire Event” when I need it. The javascript code goes like below
javascript:
var a = []; // for storing temp array
var i = 3; // put period every 3 digits
var ss = document.getElementById('cache1').innerText; // cache1 is the id of the widget in the HTML
var s = ss.split("").reverse().join(""); // reverse the string, for example, 3000.00 -> 00.0003
do{ a.push(s.substring(0, i)) } // a loop to split the string into groups, each with a length of 3, so 00.0003 -> ["00.", "000", "3"]
while( (s = s.substring(i, s.length)) != "" );
xx=a.join(".").split("").reverse().join("").replace("..",","); // use period to join the array, then reverse the string, then replace .. with comma, so ["00.", "000", "3"] -> 3.000,00
document.getElementById('cache1').innerText = xx; // set the new formatted number to the desired widget
void(0); // exit function normally
Then the last question: how to find the id of the desired widget in the HTML => right click on the webpage, click Inspect, select the widget, the name shown in the “id” field of the HTML code is what you need