Format #text to currency

Help please
How to make #text/#input become format currency ?

$w.onReady(function () {
//AYAM MENTEGA
$w(‘#buttonM1’).onClick((event) => {
$w(‘#inputM1’).value = Number($w(‘#inputM1’).value) - 1;
$w(“#input6”).value = Number($w(“#inputM1”).value) * 13.000;
$w(“#text71”).text = $w(“#input6”).value
let value = $w(“#text71”).text;
let stringDigits = value.rep
lace(/[^0-9]/g,“”);
let finalString = stringDigits.replace(/…\B/g, “$&.”);
$w(“#text71”).text = finalString;
});
//AYAM ASAM MANIS
$w(‘#buttonA1’).onClick((event) => {
$w(‘#inputA1’).value = Number($w(‘#inputA1’).value) - 1;
$w(“#input7”).value = Number($w(“#inputA1”).value) * 16000;
$w(“#text72”).text = $w(“#input7”).value
let value = $w(“#text72”).text;
let stringDigits = value.replace(/[^0-9]/g,“”);
let finalString = stringDigits.replace(/…\B/g, “$&.”);
$w(“#text72”).text = finalString;
});

There’s a built-in JavaScript method to format number as currency string.
For example:

//To US Dollar:
number.toLocaleString('en-US', { style: 'currency', currency: 'USD' });

//to Euro:
number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' });

//To Indonesian Rupiahs
number.toLocaleString('id-ID', { style: 'currency', currency: 'IDR' });

Would anyone be able to tell me where this goes? My coding knowledge is minimal.
I’m looking to change a text field thats pulling info from a collection, to a currency format. Currently it displays as a number (no $, or commas).

I know this is an old post but i’m running out of options. Thanks in advance!

In the page code panel (after you turn Dev Mode on).
But what what adjustments should be done depends on the specific scenario,

@jonatandor35 Thanks J.D.
I’ve currently got this code

export function propertiesRepeater_itemReady ( $item , itemData , index ) {
let currentPrice = itemData.price ;
let newPrice = “$” + formatNumber_AsDollar ( currentPrice );
$item ( “#price” ). text = newPrice ;

let currentSQFT = itemData.size ;
let newSQFT = ( currentSQFT ) + " SQFT" ;
$item ( “#text7” ). text = newSQFT ;
}

function formatNumber_AsDollar ( x ) {
return x . toString (). replace (/\B(?=(\d{3})+(?!\d))/ g , “,” );
}

This corrects the displayed number/text to a currency format for items within the repeater.

What I’m aiming to to do is have the same adjustment happen to the price field on the “Title” page of the repeater (the page that loads after a user clicks on an item in the repeater). On this page I have a text field (#price) that is pulling info from a dynamic dataset. This is the field that I would need to target with your java code from above.

I hope that helps clear things up a bit. Let me know if you have any other questions. Thanks for your quick response J.D.